From: Alexander Smirnov Date: Tue, 1 Apr 2025 07:16:44 +0000 (+0300) Subject: [ERP-381] created_by and etc. X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=912e639d38f32bfcd13013b99805e3e7b34326a4;p=erp24_rep%2Fyii-erp24%2F.git [ERP-381] created_by and etc. --- diff --git a/erp24/migrations/m250331_125814_create_Table_bouquet_composition_price.php b/erp24/migrations/m250331_125814_create_Table_bouquet_composition_price.php index 1f092d2f..b47242f4 100755 --- a/erp24/migrations/m250331_125814_create_Table_bouquet_composition_price.php +++ b/erp24/migrations/m250331_125814_create_Table_bouquet_composition_price.php @@ -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('ИД редактировавшего'), ]); } } diff --git a/erp24/records/BouquetCompositionPrice.php b/erp24/records/BouquetCompositionPrice.php index 03588cb0..fed13915 100644 --- a/erp24/records/BouquetCompositionPrice.php +++ b/erp24/records/BouquetCompositionPrice.php @@ -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', ]; } }