/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Records::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['specialist_id' => SORT_DESC, 'start_time' => SORT_ASC]]]); // $dataProvider->setSort([ // 'attributes' => [ // 'start_time', // 'occupationName', // ] // ]); $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->joinWith('specialist.doctor'); $query->joinWith('specialist.occupation'); // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'cabinet_id' => $this->cabinet_id, 'reserved' => $this->reserved, 'visited' => $this->visited, 'sum' => $this->sum, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'records.start_time', $this->start_time])->AndFilterWhere(['like', 'doctors.name', $this->specialist_id])->AndFilterWhere(['like', 'occupations.name', $this->occupationName])->andFilterWhere(['like', 'records.name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
public static function actionGetRequest($date_from, $date_to, $specialist_id) { $result = Records::find()->where(['specialist_id' => $specialist_id, 'DAY(start_time)' => $day, 'MONTH(start_time)' => $month, 'YEAR(start_time)' => $year])->all(); return Json::encode($result); }