namespace yii_app\actions\timetable;
use yii_app\records\AdminGroup;
+use yii_app\records\Shift;
use yii_app\records\Timetable;
use yii_app\records\TimetableFactModel;
use Yii;
$model->load($this->controller->request->post());
$model->photo = UploadedFile::getInstance($model, 'photo');
$validate = $model->validate();
+ $maxShiftDuration = max(ArrayHelper::getColumn(Shift::all(), 'duration'));
+ var_dump(AdminCheckin::find()
+ ->andWhere(['admin_id' => $this->admin_id])
+ ->andWhere(['>', 'time', date('Y-m-d H:i:s', strtotime("-$maxShiftDuration hour"))])
+ ->orderBy(['time' => SORT_DESC])
+ ->limit(1)->createCommand()->getRawSql());
var_dump($model->getErrors(), $model);die();
if ($validate) {
$model->save();