public function run() { if (($model = Holidays::find()->where(['status_holiday' => Holidays::STATUS_ACTIVE, 'date_holiday' => Holidays::getMaxdate()])->limit(1)->all()) !== null) { return $this->render('holiday', ['model' => $model]); } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Holidays::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'date_holiday' => $this->date_holiday, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'name_holiday', $this->name_holiday])->andFilterWhere(['like', 'text_holiday', $this->text_holiday])->andFilterWhere(['like', 'logo_holiday', $this->logo_holiday])->andFilterWhere(['like', 'status_holiday', $this->status_holiday]); return $dataProvider; }
public function actionView($slug) { $model = Holidays::find()->where(['slug' => $slug])->one(); return $this->render('view', ['model' => $model]); }
public function getMaxdate() { return Holidays::find()->where(['status_holiday' => Holidays::STATUS_ACTIVE])->max('date_holiday'); }