protected function findModel($id) { if (($model = \plathir\smartblog\backend\models\Category::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'active' => $this->active]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'name' => $this->name, 'description' => $this->description]); // $query->andFilterWhere(['like', 'description', $this->description]) // ->andFilterWhere(['like', 'intro_text', $this->intro_text]) // ->andFilterWhere(['like', 'full_text', $this->full_text]) // ->andFilterWhere(['like', 'intro_image', $this->intro_image]) // ->andFilterWhere(['like', "date_format(date(from_unixtime(created_at)) ,'%d-%m-%Y' )", $date_cr]) // ->andFilterWhere(['like', "date_format(date(from_unixtime(updated_at)) ,'%d-%m-%Y' )", $date_up]); // return $dataProvider; }