/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ViewerGroup::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } if (isset($_GET['viewer_id'])) { $viewer_id = $_GET['viewer_id']; } else { $viewer_id = $this->viewer_id; } $query->andFilterWhere(['id' => $this->id, 'viewer_id' => $viewer_id, 'group_id' => $this->group_id]); return $dataProvider; }
/** * Finds the ViewerGroup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id_viewer * @param integer $id_group * @return ViewerGroup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ViewerGroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }