/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notifications::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['NotificationID' => $this->NotificationID, 'PostID' => $this->PostID, 'NotificationFrom' => $this->NotificationFrom, 'TimeStamp' => $this->TimeStamp]); $query->andFilterWhere(['like', 'NotificationContent', $this->NotificationContent])->andFilterWhere(['like', 'NotificationType', $this->NotificationType]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notifications::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, 'driver_license' => $this->driver_license, 'truck_act' => $this->truck_act, 'truck_period' => $this->truck_period]); return $dataProvider; }
public function actionIndex() { $query = Notifications::find()->where(['notification_type' => 'all']); $dataProvider = new ActiveDataProvider(['query' => $query]); return $this->render('index', ['dataProvider' => $dataProvider]); }