Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Event::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, 'user_id' => $this->user_id, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'visibility' => $this->visibility, 'region_id' => $this->region_id, 'genre_id' => $this->genre_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'location', $this->location])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionGetNumberOfEvents()
 {
     $now = new \DateTime(Yii::$app->request->post('now'));
     $nextMonth = new \DateTime(Yii::$app->request->post('nextMonth'));
     $array = [];
     for ($date = $now; $date < $nextMonth; $date->modify('+1 day')) {
         $hasEvent = true;
         $event = Event::find()->joinWith('eventPosts')->where(['like', 'DATE(start_date)', $date->format('Y-m-d')])->andWhere('status = :status', [':status' => EventPost::STATUS_POST])->one();
         if ($event) {
             $hasEvent = true;
         } else {
             $hasEvent = false;
         }
         $array[] = ['date' => $date->format('Y-m-d H:i:s'), 'hasEvent' => $hasEvent];
     }
     return json_encode(['success' => true, 'data' => $array]);
 }
Ejemplo n.º 3
0
 /**
  * Lists all Event models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Event::find()]);
     $dataProvider->setSort(['defaultOrder' => ['created_at' => SORT_DESC, 'id' => SORT_ASC]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }