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".
* @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
{
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'],
];
}
'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',
];
}
}