/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Samochod::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['rocznik' => SORT_DESC]], 'pagination' => ['pageSize' => $this->pageSize]]); $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->andFilterWhere(['id' => $this->id, 'rocznik' => $this->rocznik, 'pojemnosc' => $this->pojemnosc, 'cena' => $this->cena]); $query->andFilterWhere(['like', 'model', $this->model])->andFilterWhere(['like', 'zdjecie1', $this->zdjecie1])->andFilterWhere(['like', 'zdjecie2', $this->zdjecie2])->andFilterWhere(['like', 'zdjecie3', $this->zdjecie3])->andFilterWhere(['like', 'zdjecie4', $this->zdjecie4])->andFilterWhere(['like', 'miniatura', $this->miniatura])->andFilterWhere(['like', 'opis', $this->opis]); return $dataProvider; }
/** * Finds the Samochod model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Samochod the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Samochod::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }