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.
99 lines
2.7 KiB
99 lines
2.7 KiB
5 years ago
|
<?php
|
||
|
|
||
|
namespace common\models;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "fix_car_part".
|
||
|
*
|
||
|
* @property integer $id
|
||
|
* @property integer $series_id
|
||
|
* @property integer $displacement_id
|
||
|
* @property integer $year_id
|
||
|
* @property string $created_at
|
||
|
* @property string $updated_at
|
||
|
*
|
||
|
* @property DisplacementT $displacement
|
||
|
* @property SeriesT $series
|
||
|
* @property YearT $year
|
||
|
* @property MiddlePartStoreRoom[] $middlePartStoreRooms
|
||
|
*/
|
||
|
class FixCarPart extends \common\models\Base
|
||
|
{
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return 'fix_car_part';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['series_id', 'displacement_id', 'year_id'], 'integer'],
|
||
|
[['created_at', 'updated_at'], 'safe'],
|
||
|
[['series_id', 'displacement_id', 'year_id'], 'unique', 'targetAttribute' => ['series_id', 'displacement_id', 'year_id'], 'message' => 'The combination of Series ID, Displacement ID and Year ID has already been taken.'],
|
||
|
[['displacement_id'], 'exist', 'skipOnError' => true, 'targetClass' => DisplacementT::className(), 'targetAttribute' => ['displacement_id' => 'id']],
|
||
|
[['series_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeriesT::className(), 'targetAttribute' => ['series_id' => 'id']],
|
||
|
[['year_id'], 'exist', 'skipOnError' => true, 'targetClass' => YearT::className(), 'targetAttribute' => ['year_id' => 'id']],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'series_id' => 'Series ID',
|
||
|
'displacement_id' => 'Displacement ID',
|
||
|
'year_id' => 'Year ID',
|
||
|
'created_at' => 'Created At',
|
||
|
'updated_at' => 'Updated At',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @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']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getYear()
|
||
|
{
|
||
|
return $this->hasOne(YearT::className(), ['id' => 'year_id']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return \yii\db\ActiveQuery
|
||
|
*/
|
||
|
public function getMiddlePartStoreRooms()
|
||
|
{
|
||
|
return $this->hasMany(MiddlePartStoreRoom::className(), ['part_id' => 'id']);
|
||
|
}
|
||
|
|
||
|
public function getStoreRooms(){
|
||
|
return $this->hasMany(StoreRoom::className(),['id'=>'store_room_id'])
|
||
|
->via('middlePartStoreRooms');
|
||
|
}
|
||
|
}
|