namespace yii_app\records;
use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
/**
* This is the model class for table "product_1c_replacement".
return 'product_1c_replacement';
}
+ public function behaviors(): array
+ {
+ return [
+ [
+ 'class' => TimestampBehavior::class,
+ 'createdAtAttribute' => 'created_at',
+ 'updatedAtAttribute' => 'updated_at',
+ 'value' => new Expression('NOW()'),
+ ],
+ ];
+ }
+
/**
* {@inheritdoc}
*/
$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());