public function rules()
{
return [
- [['date', 'item_id', 'location_id', 'state_id'], 'required'],
- [['date'], 'safe'],
- [['date'], 'date', 'format' => 'dd.MM.yyyy' ],
- [['date'], 'checkValidDate'],
- [['item_id', 'location_id', 'state_id'], 'default', 'value' => null],
- [['id', 'item_id', 'location_id', 'state_id'], 'integer'],
- [['comment'], 'string'],
- [['item_id'], 'exist', 'skipOnError' => true, 'targetClass' => Items::className(), 'targetAttribute' => ['item_id' => 'id']],
- [['location_id'], 'exist', 'skipOnError' => true, 'targetClass' => Locations::className(), 'targetAttribute' => ['location_id' => 'id']],
- [['state_id'], 'exist', 'skipOnError' => true, 'targetClass' => Status::className(), 'targetAttribute' => ['state_id' => 'id']],
+ [[ 'date', 'item_id', 'location_id', 'state_id'], 'required' ],
+ [[ 'date', 'itemModel' ], 'safe' ],
+ [[ 'date'], 'date', 'format' => 'dd.MM.yyyy' ],
+ [[ 'date'], 'checkValidDate' ],
+ [[ 'item_id', 'location_id', 'state_id' ], 'default', 'value' => NULL ],
+ [[ 'id', 'item_id', 'location_id', 'state_id' ], 'integer' ],
+ [[ 'comment' ], 'string'],
+ [[ 'item_id' ], 'exist', 'skipOnError' => true, 'targetClass' => Items::className(), 'targetAttribute' => [ 'item_id' => 'id' ]],
+ [[ 'location_id' ], 'exist', 'skipOnError' => true, 'targetClass' => Locations::className(), 'targetAttribute' => [ 'location_id' => 'id' ]],
+ [[ 'state_id' ], 'exist', 'skipOnError' => true, 'targetClass' => Status::className(), 'targetAttribute' => [ 'state_id' => 'id' ]],
];
}
$this->addError('date', Yii::t('moving', 'The date cannot be more than today'));
} else
{
- if ($date < strtotime('01.01.1990'))
+ if ($date < strtotime('01.01.1900'))
{
- $this->addError('date', Yii::t('moving', 'Date cannot be less than {date}', [ 'date' => '01.01.1990' ]));
+ $this->addError('date', Yii::t('moving', 'Date cannot be less than {date}', [ 'date' => '01.01.1900' ]));
} else
{
$item_id = $this->item_id;
return $this->hasOne(Items::className(), [ 'id' => 'item_id' ]);
}
+ public function getModels()
+ {
+ return $this->getItems()->select(Models::tableName() . '.*')->joinWith('models');
+ }
+
+ public function getTypes()
+ {
+ return $this->getModels()->select(Types::tableName() . '.*')->joinWith('types');
+ }
+
/**
* Получение связанной таблицы места размещения.
*