Browse Source

add model

Oleg K 2 years ago
parent
commit
a117b898a2
2 changed files with 102 additions and 0 deletions
  1. 68 0
      models/ReferralLink.php
  2. 34 0
      models/ReferralLinkQuery.php

+ 68 - 0
models/ReferralLink.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace reactlogic\referral\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "referral_link".
+ *
+ * @property int $id
+ * @property string $title
+ * @property string $source
+ * @property string|null $link
+ * @property string|null $link_hash
+ * @property int $clicks
+ * @property int $registrations
+ * @property int|null $owner
+ */
+class ReferralLink extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'referral_link';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['title', 'source', 'clicks', 'registrations'], 'required'],
+            [['link'], 'string'],
+            [['clicks', 'registrations', 'owner'], 'integer'],
+            [['title', 'source', 'link_hash'], 'string', 'max' => 191],
+            [['link_hash'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => Yii::t('app', 'ID'),
+            'title' => Yii::t('app', 'Title'),
+            'source' => Yii::t('app', 'Source'),
+            'link' => Yii::t('app', 'Link'),
+            'link_hash' => Yii::t('app', 'Link Hash'),
+            'clicks' => Yii::t('app', 'Clicks'),
+            'registrations' => Yii::t('app', 'Registrations'),
+            'owner' => Yii::t('app', 'Owner'),
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     * @return ReferralLinkQuery the active query used by this AR class.
+     */
+    public static function find()
+    {
+        return new ReferralLinkQuery(get_called_class());
+    }
+}

+ 34 - 0
models/ReferralLinkQuery.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace reactlogic\referral\models;
+
+/**
+ * This is the ActiveQuery class for [[ReferralLink]].
+ *
+ * @see ReferralLink
+ */
+class ReferralLinkQuery extends \yii\db\ActiveQuery
+{
+    /*public function active()
+    {
+        return $this->andWhere('[[status]]=1');
+    }*/
+
+    /**
+     * {@inheritdoc}
+     * @return ReferralLink[]|array
+     */
+    public function all($db = null)
+    {
+        return parent::all($db);
+    }
+
+    /**
+     * {@inheritdoc}
+     * @return ReferralLink|array|null
+     */
+    public function one($db = null)
+    {
+        return parent::one($db);
+    }
+}