]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-381] created_by and etc.
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 1 Apr 2025 07:16:44 +0000 (10:16 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 1 Apr 2025 07:16:44 +0000 (10:16 +0300)
erp24/migrations/m250331_125814_create_Table_bouquet_composition_price.php
erp24/records/BouquetCompositionPrice.php

index 1f092d2fde0d07a9bdc3f53bd3ba8c9792cf9d26..b47242f47543a901cadeb43055a7f5dda1de7236 100755 (executable)
@@ -28,6 +28,10 @@ class m250331_125814_create_Table_bouquet_composition_price extends Migration
                 'price' => $this->float()->notNull()->comment('Цена + наценка ~= selfcost * 130% * 115%'),
                 'price_markup' => $this->float()->notNull()->defaultValue(15.0)
                     ->comment('Наценка над базовой ценой = себестоимостью * 130%. По умолчанию 15%'),
+                'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+                'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
+                'created_by' => $this->integer()->notNull()->comment('ИД создателя'),
+                'updated_by' => $this->integer()->null()->comment('ИД редактировавшего'),
             ]);
         }
     }
index 03588cb09b00f4f64fcec5c3538763fea2da57b9..fed1391520b97a5aa69698c7a84106769632256e 100644 (file)
@@ -3,6 +3,9 @@
 namespace yii_app\records;
 
 use Yii;
+use yii\behaviors\BlameableBehavior;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
 
 /**
  * This is the model class for table "bouquet_composition_price".
@@ -15,6 +18,10 @@ use Yii;
  * @property float $selfcost_markup_price Наценка над себестоимостью в рублёвом эквиваленте
  * @property float $price Цена + наценка ~= selfcost * 130% * 115%
  * @property float $price_markup Наценка над базовой ценой = себестоимостью * 130%. По умолчанию 15%
+ * @property string $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property int $created_by ИД создателя
+ * @property int|null $updated_by ИД редактировавшего
  */
 class BouquetCompositionPrice extends \yii\db\ActiveRecord
 {
@@ -26,16 +33,34 @@ class BouquetCompositionPrice extends \yii\db\ActiveRecord
         return 'bouquet_composition_price';
     }
 
+    public function behaviors(): array
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'createdAtAttribute' => 'created_at',
+                'updatedAtAttribute' => 'updated_at',
+                'value' => new Expression('NOW()'),
+            ],
+            [
+                'class' => BlameableBehavior::class,
+                'createdByAttribute' => 'created_by',
+                'updatedByAttribute' => 'updated_by',
+            ],
+        ];
+    }
+
     /**
      * {@inheritdoc}
      */
     public function rules()
     {
         return [
-            [['bouquet_id', 'region_id', 'selfcost', 'selfcost_markup_price', 'price'], 'required'],
-            [['bouquet_id', 'region_id'], 'default', 'value' => null],
-            [['bouquet_id', 'region_id'], 'integer'],
+            [['bouquet_id', 'region_id', 'selfcost', 'selfcost_markup_price', 'price', 'created_at', 'created_by'], 'required'],
+            [['bouquet_id', 'region_id', 'created_by', 'updated_by'], 'default', 'value' => null],
+            [['bouquet_id', 'region_id', 'created_by', 'updated_by'], 'integer'],
             [['selfcost', 'selfcost_markup', 'selfcost_markup_price', 'price', 'price_markup'], 'number'],
+            [['created_at', 'updated_at'], 'safe'],
         ];
     }
 
@@ -53,6 +78,10 @@ class BouquetCompositionPrice extends \yii\db\ActiveRecord
             'selfcost_markup_price' => 'Selfcost Markup Price',
             'price' => 'Price',
             'price_markup' => 'Price Markup',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+            'created_by' => 'Created By',
+            'updated_by' => 'Updated By',
         ];
     }
 }