Example #1
0
 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.');
     }
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 public function actionView($slug)
 {
     $model = Holidays::find()->where(['slug' => $slug])->one();
     return $this->render('view', ['model' => $model]);
 }
Example #4
0
 public function getMaxdate()
 {
     return Holidays::find()->where(['status_holiday' => Holidays::STATUS_ACTIVE])->max('date_holiday');
 }
Example #5
0
 /**
  * Finds the Holidays model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Holidays the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Holidays::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }