<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_car_group".
 *
 * @property integer $id
 * @property integer $pid
 * @property string $name
 * @property string $created_at
 * @property string $updated_at
 */
class FixCarGroup extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_car_group';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['pid', 'name'], 'required'],
            [['pid'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['name'], 'string', 'max' => 100],
            [['name','pid'],'required']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'pid' => 'Pid',
            'name' => '分组名',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
    public function getCategory(){
        return $this->hasMany(FixCarCategory::className(),['id'=>'fix_car_category_id'])
            ->viaTable('middle_group_category',['fix_group_id'=>'id']);
    }
}
