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.
130 lines
3.7 KiB
130 lines
3.7 KiB
5 years ago
|
<?php
|
||
|
|
||
|
namespace common\models;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "fix_purchase_item".
|
||
|
*
|
||
|
* @property integer $id
|
||
|
* @property string $name
|
||
|
* @property integer $brand_id
|
||
|
* @property integer $series_id
|
||
|
* @property integer $displacement_id
|
||
|
* @property integer $car_year
|
||
|
* @property integer $status
|
||
|
* @property integer $get_user
|
||
|
* @property string $get_at
|
||
|
* @property integer $number
|
||
|
* @property string $price
|
||
|
* @property string $created_at
|
||
|
* @property string $updated_at
|
||
|
*
|
||
|
* @property UserT $getUser
|
||
|
* @property BrandT $brand
|
||
|
* @property YearT $carYear
|
||
|
* @property DisplacementT $displacement
|
||
|
* @property SeriesT $series
|
||
|
*/
|
||
|
class FixPurchaseItem extends \common\models\Base
|
||
|
{
|
||
|
public function scenarios()
|
||
|
{
|
||
|
return [
|
||
|
'default'=>['name','brand_id','series_id','displacement_id','car_year','!status','!get_user','number','price'],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return 'fix_purchase_item';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['brand_id', 'series_id', 'displacement_id', 'car_year', 'status', 'get_user', 'number','is_del'], 'integer'],
|
||
|
[['get_at', 'created_at', 'updated_at'], 'safe'],
|
||
|
[['price'], 'number'],
|
||
|
[['name'], 'string', 'max' => 100],
|
||
|
[['name'], 'unique'],
|
||
|
[['get_user'], 'exist', 'skipOnError' => true, 'targetClass' => UserT::className(), 'targetAttribute' => ['get_user' => 'id']],
|
||
|
[['brand_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandT::className(), 'targetAttribute' => ['brand_id' => 'id']],
|
||
|
[['car_year'], 'exist', 'skipOnError' => true, 'targetClass' => YearT::className(), 'targetAttribute' => ['car_year' => 'id']],
|
||
|
[['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
|
||
|
[['series_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeriesT::className(), 'targetAttribute' => ['series_id' => 'id']],
|
||
|
[['brand_id','series_id','displacement_id','number','price','name'],'required','on'=>'default']
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'name' => '配件名',
|
||
|
'brand_id' => '品牌',
|
||
|
'series_id' => '车型',
|
||
|
'displacement_id' => '排量',
|
||
|
'car_year' => '年款',
|
||
|
'status' => 'Status',
|
||
|
'get_user' => 'Get User',
|
||
|
'get_at' => 'Get At',
|
||
|
'number' => '数量',
|
||
|
'price' => '单价',
|
||
|
'is_del' => 'Is Del',
|
||
|
'created_at' => 'Created At',
|
||
|
'updated_at' => 'Updated At',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getGetUser()
|
||
|
{
|
||
|
return $this->hasOne(UserT::className(), ['id' => 'get_user']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getBrand()
|
||
|
{
|
||
|
return $this->hasOne(BrandT::className(), ['id' => 'brand_id']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getCarYear()
|
||
|
{
|
||
|
return $this->hasOne(YearT::className(), ['id' => 'car_year']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getDisplacement()
|
||
|
{
|
||
|
return $this->hasOne(DisplacementT::className(), ['id' => 'displacement_id']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getSeries()
|
||
|
{
|
||
|
return $this->hasOne(SeriesT::className(), ['id' => 'series_id']);
|
||
|
}
|
||
|
}
|