/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TempLost::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; } $query->andFilterWhere(['id' => $this->id, 'cat_id' => $this->cat_id, 'cat_1' => $this->cat_1, 'cat_2' => $this->cat_2, 'cat_3' => $this->cat_3, 'user_id' => $this->user_id, 'lost_id' => $this->lost_id, 'date' => $this->date]); $query->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'status_m', $this->status_m])->andFilterWhere(['like', 'status_f', $this->status_f])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Finds the TempLost model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TempLost the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TempLost::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }