<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "appointment_history_t".
 *
 * @property integer $id
 * @property integer $car_id
 * @property integer $user_id
 * @property string $pdate
 * @property string $ptime
 * @property string $remark
 * @property string $created_at
 * @property string $updated_at
 */
class AppointmentHistoryT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'appointment_history_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['car_id', 'user_id'], 'required'],
            [['car_id', 'user_id', 'business_group_id'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['pdate', 'ptime'], 'string', 'max' => 50],
            [['remark'], 'string', 'max' => 500],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'car_id' => 'Car ID',
            'user_id' => 'User ID',
            'pdate' => 'Pdate',
            'ptime' => 'Ptime',
            'ptype' => 'Ptype',
            'remark' => 'Remark',
            'business_group_id' => 'Business Group Id',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

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

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

    public function getBusinessGroup()
    {
        return $this->hasOne(BusinessGroupT::className(), ['id' => 'business_group_id']);
    }
}
