From: Alexander Smirnov Date: Fri, 4 Apr 2025 11:50:04 +0000 (+0300) Subject: [ERP-396] timebehvaior X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=b783b99feec644dd87dbb4a55b968b8e8a917666;p=erp24_rep%2Fyii-erp24%2F.git [ERP-396] timebehvaior --- diff --git a/erp24/records/Product1cReplacement.php b/erp24/records/Product1cReplacement.php index 5b177bd8..e3b97eed 100644 --- a/erp24/records/Product1cReplacement.php +++ b/erp24/records/Product1cReplacement.php @@ -3,6 +3,8 @@ namespace yii_app\records; use Yii; +use yii\behaviors\TimestampBehavior; +use yii\db\Expression; /** * This is the model class for table "product_1c_replacement". @@ -25,6 +27,18 @@ class Product1cReplacement extends \yii\db\ActiveRecord return 'product_1c_replacement'; } + public function behaviors(): array + { + return [ + [ + 'class' => TimestampBehavior::class, + 'createdAtAttribute' => 'created_at', + 'updatedAtAttribute' => 'updated_at', + 'value' => new Expression('NOW()'), + ], + ]; + } + /** * {@inheritdoc} */ diff --git a/erp24/services/Product1cReplacementService.php b/erp24/services/Product1cReplacementService.php index 31dc13e7..02090ef6 100644 --- a/erp24/services/Product1cReplacementService.php +++ b/erp24/services/Product1cReplacementService.php @@ -62,7 +62,6 @@ class Product1cReplacementService { $rep = new Product1cReplacement; $rep->guid = $productGuid; $rep->guid_replacement = $repGuid; - $rep->created_at = date('Y-m-d H:i:s'); $rep->save(); if ($rep->getErrors()) { $errors [] = Json::encode($rep->getErrors());