<?php
    
    namespace backend\models;
    
    use common\models\Customer;
    use Yii;
    
    class Orders extends \yii\db\ActiveRecord
    {
        
        public $labels;
        
        public static function tableName()
        {
            return 'orders';
        }
        
        public function rules()
        {
            return [
                [
                    [ 'name' ],
                    'required',
                ],
                [
                    [
                        'user_id',
                        'adress',
                        'body',
                        'total',
                        'status',
                        'email',
                        'comment',
                        'labels',
                        'pay',
                        'date_dedline',
                        'phone',
                        'phone2',
                        'numbercard',
                        'delivery',
                        'declaration',
                        'stock',
                        'consignment',
                        'payment',
                        'insurance',
                        'amount_imposed',
                        'shipping_by',
                        'city',
                        'date_time',
                        'id',
                    ],
                    'safe',
                ],
            ];
        }
        
        public function attributeLabels()
        {
            return [
                'id'             => Yii::t('app', 'orders_id'),
                'name'           => Yii::t('app', 'orders_name'),
                'phone'          => Yii::t('app', 'orders_phone'),
                'phone2'         => Yii::t('app', 'orders_phone2'),
                'adress'         => Yii::t('app', 'orders_adress'),
                'body'           => Yii::t('app', 'orders_body'),
                'reserve'        => Yii::t('app', 'orders_reserve'),
                'status'         => Yii::t('app', 'orders_status'),
                'email'          => Yii::t('app', 'orders_email'),
                'total'          => Yii::t('app', 'orders_total'),
                'labels'         => Yii::t('app', 'orders_labels'),
                'label'          => Yii::t('app', 'orders_label'),
                'comment'        => Yii::t('app', 'orders_comment'),
                'date_dedline'   => Yii::t('app', 'orders_date_dedline'),
                'numbercard'     => Yii::t('app', 'orders_numbercard'),
                'delivery'       => Yii::t('app', 'orders_delivery'),
                'declaration'    => Yii::t('app', 'orders_declaration'),
                'stock'          => Yii::t('app', 'orders_stock'),
                'consignment'    => Yii::t('app', 'orders_consignment'),
                'payment'        => Yii::t('app', 'orders_payment'),
                'insurance'      => Yii::t('app', 'orders_insurance'),
                'amount_imposed' => Yii::t('app', 'orders_amount_imposed'),
                'shipping_by'    => Yii::t('app', 'orders_shipping_by'),
                'city'           => Yii::t('app', 'orders_city'),
                'date_time'      => Yii::t('app', 'orders_datetime'),
            ];
        }
        
        public function getUser()
        {
            return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]);
        }
        
    }