diff --git a/models/Order.php b/models/Order.php index eed66cb..0b93dd4 100755 --- a/models/Order.php +++ b/models/Order.php @@ -3,6 +3,7 @@ use artweb\artbox\models\Customer; use Yii; + use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; use yii\db\Expression; use yii\web\Session; @@ -12,32 +13,35 @@ * * @todo Write docs and refactor * @package artweb\artbox\ecommerce\models - * @property int $id - * @property int $user_id - * @property string $name - * @property string $phone - * @property string $phone2 - * @property string $email - * @property string $adress - * @property string $body - * @property double $total - * @property string $date_time - * @property string $date_dedline - * @property string $reserve - * @property string $status - * @property string $comment - * @property int $label - * @property int $pay - * @property int $numbercard - * @property int $delivery - * @property string $declaration - * @property string $stock - * @property string $consignment - * @property string $payment - * @property string $insurance - * @property double $amount_imposed - * @property string $shipping_by - * @property string $city + * @property integer $created_at + * @property integer $updated_at + * @property integer $deleted_at + * @property int $id + * @property int $user_id + * @property string $name + * @property string $phone + * @property string $phone2 + * @property string $email + * @property string $adress + * @property string $body + * @property double $total + * @property string $date_time + * @property string $date_dedline + * @property string $reserve + * @property string $status + * @property string $comment + * @property int $label + * @property int $pay + * @property int $numbercard + * @property int $delivery + * @property string $declaration + * @property string $stock + * @property string $consignment + * @property string $payment + * @property string $insurance + * @property double $amount_imposed + * @property string $shipping_by + * @property string $city */ class Order extends ActiveRecord { @@ -62,11 +66,28 @@ return $scenarios; } + public function behaviors() + { + return [ + [ + 'class' => TimestampBehavior::className(), + ], + ]; + } + public function rules() { return [ [ [ + 'created_at', + 'updated_at', + 'deleted_at', + ], + 'integer', + ], + [ + [ 'phone', ], 'required', @@ -121,24 +142,27 @@ public function attributeLabels() { return [ - 'name' => Yii::t('app', 'order_name'), - 'phone' => Yii::t('app', 'order_phone'), - 'email' => Yii::t('app', 'order_email'), - 'comment' => Yii::t('app', 'order_comment'), + 'name' => Yii::t('app', 'order_name'), + 'phone' => Yii::t('app', 'order_phone'), + 'email' => Yii::t('app', 'order_email'), + 'comment' => Yii::t('app', 'order_comment'), + 'created_at' => Yii::t('app', 'Дата добавления'), + 'updated_at' => Yii::t('app', 'Дата обновления'), + 'deleted_at' => Yii::t('app', 'Дата удаления'), ]; } - public function beforeSave($insert) - { - $this->user_id = Yii::$app->user->id; - $this->date_time = new Expression('NOW()'); - return parent::beforeSave($insert); - } - - public function beforeDelete() - { - return parent::beforeDelete(); - } + // public function beforeSave($insert) + // { + // $this->user_id = Yii::$app->user->id; + // $this->date_time = new Expression('NOW()'); + // return parent::beforeSave($insert); + // } + // + // public function beforeDelete() + // { + // return parent::beforeDelete(); + // } public function addBasket($product_variant_id, $count) { -- libgit2 0.21.4