]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Создал таблицу sent_kogort и модель
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 20 Dec 2024 13:22:49 +0000 (16:22 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 20 Dec 2024 13:22:49 +0000 (16:22 +0300)
erp24/migrations/m241220_131428_create_sent_kogort_table.php [new file with mode: 0644]
erp24/records/SentKogort.php [new file with mode: 0644]

diff --git a/erp24/migrations/m241220_131428_create_sent_kogort_table.php b/erp24/migrations/m241220_131428_create_sent_kogort_table.php
new file mode 100644 (file)
index 0000000..80fb59d
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%sent_kogort}}`.
+ */
+class m241220_131428_create_sent_kogort_table extends Migration
+{
+    const TABLE_NAME  = 'erp24.sent_kogort';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (!isset($tableSchema)) {
+            $this->createTable(self::TABLE_NAME, [
+                'id' => $this->primaryKey(),
+                'phone' => $this->string(15)->notNull()->comment('Телефон пользователя'),
+                'kogort_date' => $this->date()->notNull()->comment('Дата когорты'),
+                'kogort_unixtime' => $this->integer()->notNull()->comment('UNIX-время когорты'),
+                'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('Вхождение в когорту'),
+                'contact' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('Контакт с клиентом'),
+                'purchase' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('Покупка'),
+                'created_at' => $this->dateTime()->notNull()->comment('Дата создания записи'),
+            ]);
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if (isset($tableSchema)) {
+            $this->dropTable(self::TABLE_NAME);
+        }
+    }
+}
diff --git a/erp24/records/SentKogort.php b/erp24/records/SentKogort.php
new file mode 100644 (file)
index 0000000..575d59a
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "sent_kogort".
+ *
+ * @property int $id
+ * @property string $phone Телефон пользователя
+ * @property string $kogort_date Дата когорты
+ * @property int $kogort_unixtime UNIX-время когорты
+ * @property int $status Вхождение в когорту
+ * @property int $contact Контакт с клиентом
+ * @property int $purchase Покупка
+ * @property string $created_at Дата создания записи
+ */
+class SentKogort extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'sent_kogort';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['phone', 'kogort_date', 'kogort_unixtime', 'created_at'], 'required'],
+            [['kogort_date', 'created_at'], 'safe'],
+            [['kogort_unixtime', 'status', 'contact', 'purchase'], 'default', 'value' => null],
+            [['kogort_unixtime', 'status', 'contact', 'purchase'], 'integer'],
+            [['phone'], 'string', 'max' => 15],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'phone' => 'Телефон пользователя',
+            'kogort_date' => 'Дата когорты',
+            'kogort_unixtime' => 'UNIX-время когорты',
+            'status' => 'Вхождение в когорту',
+            'contact' => 'Контакт с клиентом',
+            'purchase' => 'Покупка',
+            'created_at' => 'Дата создания записи',
+        ];
+    }
+}