/** * Creates data provider instance with search query applied * @param array $params * @return ActiveDataProvider */ public function search($params, $id_wp = 0) { if ($id_wp == 0) { $query = WpOwners::find(); } else { $query = WpOwners::find()->where(['workplace_id' => $id_wp]); } $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->joinWith('employee'); $query->andFilterWhere(['event' => $this->event, 'date' => $this->date]); $query->andFilterWhere(['like', 'employees.snp', $this->employee_id]); return $dataProvider; }
/** * Finds the WpOwners model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $workplace_id * @param integer $employee_id * @return WpOwners the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($workplace_id, $employee_id) { if (($model = WpOwners::findOne(['workplace_id' => $workplace_id, 'employee_id' => $employee_id])) !== null) { return $model; } else { throw new NotFoundHttpException('Запрашиваемая сраница недоступна'); } }