]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-396] timebehvaior
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 4 Apr 2025 11:50:04 +0000 (14:50 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 4 Apr 2025 11:50:04 +0000 (14:50 +0300)
erp24/records/Product1cReplacement.php
erp24/services/Product1cReplacementService.php

index 5b177bd84e09e75e4be5e3175bf506e95cc9e650..e3b97eedad90287204159858812aa3e40a09bbee 100644 (file)
@@ -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}
      */
index 31dc13e7f43341f43f224a21eb501998df9477d0..02090ef69324b2dff49904dfd5f03d464b5d760a 100644 (file)
@@ -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());