Commit 2b29877eafe1b8ef7564836a1cc21b7929fa1899

Authored by Alexey Boroda
1 parent 439a5483

-Added time columns to order table and behaviour

Showing 1 changed file with 65 additions and 41 deletions   Show diff stats
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 3
4 use artweb\artbox\models\Customer; 4 use artweb\artbox\models\Customer;
5 use Yii; 5 use Yii;
  6 + use yii\behaviors\TimestampBehavior;
6 use yii\db\ActiveRecord; 7 use yii\db\ActiveRecord;
7 use yii\db\Expression; 8 use yii\db\Expression;
8 use yii\web\Session; 9 use yii\web\Session;
@@ -12,32 +13,35 @@ @@ -12,32 +13,35 @@
12 * 13 *
13 * @todo Write docs and refactor 14 * @todo Write docs and refactor
14 * @package artweb\artbox\ecommerce\models 15 * @package artweb\artbox\ecommerce\models
15 - * @property int $id  
16 - * @property int $user_id  
17 - * @property string $name  
18 - * @property string $phone  
19 - * @property string $phone2  
20 - * @property string $email  
21 - * @property string $adress  
22 - * @property string $body  
23 - * @property double $total  
24 - * @property string $date_time  
25 - * @property string $date_dedline  
26 - * @property string $reserve  
27 - * @property string $status  
28 - * @property string $comment  
29 - * @property int $label  
30 - * @property int $pay  
31 - * @property int $numbercard  
32 - * @property int $delivery  
33 - * @property string $declaration  
34 - * @property string $stock  
35 - * @property string $consignment  
36 - * @property string $payment  
37 - * @property string $insurance  
38 - * @property double $amount_imposed  
39 - * @property string $shipping_by  
40 - * @property string $city 16 + * @property integer $created_at
  17 + * @property integer $updated_at
  18 + * @property integer $deleted_at
  19 + * @property int $id
  20 + * @property int $user_id
  21 + * @property string $name
  22 + * @property string $phone
  23 + * @property string $phone2
  24 + * @property string $email
  25 + * @property string $adress
  26 + * @property string $body
  27 + * @property double $total
  28 + * @property string $date_time
  29 + * @property string $date_dedline
  30 + * @property string $reserve
  31 + * @property string $status
  32 + * @property string $comment
  33 + * @property int $label
  34 + * @property int $pay
  35 + * @property int $numbercard
  36 + * @property int $delivery
  37 + * @property string $declaration
  38 + * @property string $stock
  39 + * @property string $consignment
  40 + * @property string $payment
  41 + * @property string $insurance
  42 + * @property double $amount_imposed
  43 + * @property string $shipping_by
  44 + * @property string $city
41 */ 45 */
42 class Order extends ActiveRecord 46 class Order extends ActiveRecord
43 { 47 {
@@ -62,11 +66,28 @@ @@ -62,11 +66,28 @@
62 return $scenarios; 66 return $scenarios;
63 } 67 }
64 68
  69 + public function behaviors()
  70 + {
  71 + return [
  72 + [
  73 + 'class' => TimestampBehavior::className(),
  74 + ],
  75 + ];
  76 + }
  77 +
65 public function rules() 78 public function rules()
66 { 79 {
67 return [ 80 return [
68 [ 81 [
69 [ 82 [
  83 + 'created_at',
  84 + 'updated_at',
  85 + 'deleted_at',
  86 + ],
  87 + 'integer',
  88 + ],
  89 + [
  90 + [
70 'phone', 91 'phone',
71 ], 92 ],
72 'required', 93 'required',
@@ -121,24 +142,27 @@ @@ -121,24 +142,27 @@
121 public function attributeLabels() 142 public function attributeLabels()
122 { 143 {
123 return [ 144 return [
124 - 'name' => Yii::t('app', 'order_name'),  
125 - 'phone' => Yii::t('app', 'order_phone'),  
126 - 'email' => Yii::t('app', 'order_email'),  
127 - 'comment' => Yii::t('app', 'order_comment'), 145 + 'name' => Yii::t('app', 'order_name'),
  146 + 'phone' => Yii::t('app', 'order_phone'),
  147 + 'email' => Yii::t('app', 'order_email'),
  148 + 'comment' => Yii::t('app', 'order_comment'),
  149 + 'created_at' => Yii::t('app', 'Дата добавления'),
  150 + 'updated_at' => Yii::t('app', 'Дата обновления'),
  151 + 'deleted_at' => Yii::t('app', 'Дата удаления'),
128 ]; 152 ];
129 } 153 }
130 154
131 - public function beforeSave($insert)  
132 - {  
133 - $this->user_id = Yii::$app->user->id;  
134 - $this->date_time = new Expression('NOW()');  
135 - return parent::beforeSave($insert);  
136 - }  
137 -  
138 - public function beforeDelete()  
139 - {  
140 - return parent::beforeDelete();  
141 - } 155 + // public function beforeSave($insert)
  156 + // {
  157 + // $this->user_id = Yii::$app->user->id;
  158 + // $this->date_time = new Expression('NOW()');
  159 + // return parent::beforeSave($insert);
  160 + // }
  161 + //
  162 + // public function beforeDelete()
  163 + // {
  164 + // return parent::beforeDelete();
  165 + // }
142 166
143 public function addBasket($product_variant_id, $count) 167 public function addBasket($product_variant_id, $count)
144 { 168 {