<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "ems_t".
 *
 * @property integer $id
 * @property integer $car_id
 * @property integer $order_id
 * @property integer $user_id
 * @property string $ems_company
 * @property string $ems_no
 * @property string $ems_phone
 * @property string $ems_price
 * @property string $ems_remark
 * @property string $created_at
 * @property string $updated_at
 */
class EmsT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'ems_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['car_id', 'order_id', 'user_id'], 'required'],
            [['car_id', 'order_id', 'user_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['ems_company', 'ems_remark'], 'string', 'max' => 100],
            [['ems_price','ems_no', 'ems_phone'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'car_id' => 'Car ID',
            'order_id' => 'Order ID',
            'user_id' => 'User ID',
            'ems_company' => 'Ems Company',
            'ems_no' => 'Ems No',
            'ems_phone' => 'Ems Phone',
            'ems_price' => 'Ems Price',
            'ems_remark' => 'Ems Remark',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getUser()
    {
        return $this->hasOne(UserT::className(),['id'=>'user_id']);
    }

    public function getOrder()
    {
        return $this->hasOne(OrderT::className(),['id'=>'order_id']);
    }

    public function getCar()
    {
        return $this->hasOne(CarT::className(),['id'=>'car_id']);
    }
}
