/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Trreservation::find(); $query->joinWith(['room', 'patient', 'doctor']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['room'] = ['asc' => ['msroom.RoomName' => SORT_ASC], 'desc' => ['msroom.RoomName' => SORT_DESC]]; $dataProvider->sort->attributes['patient'] = ['asc' => ['mspatient.FirstName' => SORT_ASC], 'desc' => ['mspatient.FirstName' => SORT_DESC]]; $dataProvider->sort->attributes['doctor'] = ['asc' => ['msdoctor.FirstName' => SORT_ASC], 'desc' => ['msdoctor.FirstName' => SORT_DESC]]; if (!($this->load($params) && $this->validate())) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); $query->orderBy(['Date' => SORT_DESC]); return $dataProvider; } $query->andFilterWhere(['ReservationID' => $this->ReservationID])->andFilterWhere(['like', 'Date', $this->Date])->andFilterWhere(['like', 'msroom.RoomName', $this->room])->andFilterWhere(['like', 'mspatient.FirstName', $this->patient])->andFilterWhere(['like', 'msdoctor.FirstName', $this->doctor])->orderBy(['Date' => SORT_DESC]); return $dataProvider; }
public function actionTesting() { $querytest = Trreservation::find()->all(); return $this->render('testing', ['querytest' => $querytest]); }