<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "store_room".
 *
 * @property integer $id
 * @property string $name
 * @property integer $number
 * @property integer $brand_id
 * @property integer $series_id
 * @property integer $displacement_id
 * @property integer $category_id
 * @property integer $category_1
 * @property string $car_year
 * @property string $created_at
 * @property string $updated_at
 */
class StoreList extends \common\models\Base
{
    public function scenarios()
    {
        return [
            'default'=>['number','brand_id','series_id','displacement_id','category_id','category_1','car_year','name','producing_area','price'],
            'put_out_store'=>['number']
        ];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'store_room';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['number', 'brand_id', 'series_id', 'displacement_id', 'category_id', 'category_1','price'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['name','car_year','producing_area'], 'string', 'max' => 100],
            [['number','brand_id','series_id','category_1','name','producing_area','price'],'required','on'=>'default']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '配件名称',
            'number' => '数量',
            'brand_id' => '品牌',
            'series_id' => '系列',
            'displacement_id' => '排量',
            'category_id' => 'Category ID',
            'category_1' => '分类',
            'car_year' => '年份',
            'store_area' => '仓库',
            'store_site' => '货位',
            'producing_area'=> '产地',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
    /**
     * @品牌
     */
    public function getBrand(){
        return $this->hasOne(BrandT::className(),['id'=>'brand_id']);
    }
    /**
     * @系列
     */
    public function getSeries(){
        return $this->hasOne(SeriesT::className(),['id'=>'series_id']);
    }
    /**
     * @排量
     */
    public function getDisplacement(){
        return $this->hasOne(DisplacementT::className(),['id'=>'displacement_id']);
    }
}