You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/common/models/StoreRoom.php

109 lines
3.1 KiB

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "store_room".
*
* @property integer $id
* @property string $good_sn
* @property integer $number
* @property integer $category_id
* @property integer $category_1
* @property string $producing_area
* @property string $name
* @property string $selling_price
* @property string $price
* @property string $model
* @property string $monad
* @property string $created_at
* @property string $updated_at
*
* @property MiddlePartStoreRoom[] $middlePartStoreRooms
* @property FixCarCategory $category
*/
class StoreRoom extends \common\models\Base
{
public function scenarios()
{
return [
'default'=>['number','category_id','category_1','selling_price','price','good_sn','producing_area','name','model','monad']
];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'store_room';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['number', 'category_id', 'category_1'], 'integer'],
[['selling_price', 'price'], 'number'],
[['created_at', 'updated_at'], 'safe'],
[['good_sn', 'producing_area', 'name', 'model'], 'string', 'max' => 100],
[['monad'], 'string', 'max' => 10],
[['good_sn'], 'unique'],
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => FixCarCategory::className(), 'targetAttribute' => ['category_id' => 'id']],
[['number','category_id','category_1','selling_price','price','good_sn','producing_area','name','model','monad'],'required','on'=>'default'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'good_sn' => 'Good Sn',
'number' => 'Number',
'category_id' => 'Category ID',
'category_1' => 'Category 1',
'category_2' => 'Category 2',
'producing_area' => 'Producing Area',
'name' => 'Name',
'selling_price' => 'Selling Price',
'price' => 'Price',
'model' => 'Model',
'monad' => 'Monad',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getMiddlePartStoreRooms()
{
return $this->hasMany(MiddlePartStoreRoom::className(), ['store_room_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCategory()
{
return $this->hasOne(FixCarCategory::className(), ['id' => 'category_id']);
}
public function getParts(){
return $this->hasOne(FixCarPart::className(),['id'=>'part_id'])
->via('middlePartStoreRooms');
}
public function getMaterials(){
return $this->hasOne(FixCarMateials::className(),['id'=>'store_room_id']);
}
public function getTrimsRoom(){
return $this->hasOne(FixCarTrimsRoom::className(),['id'=>'store_room_id']);
}
}