コード例 #1
0
ファイル: BlogSearch.php プロジェクト: kdes70/hotel.lok
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Blog::find();
     $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->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'user_id' => $this->user_id, 'images_id' => $this->images_id, 'publication_at' => $this->publication_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'order' => $this->order]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'prev_img', $this->prev_img]);
     return $dataProvider;
 }
コード例 #2
0
 public function actionView($slug)
 {
     $model = new Blog();
     return $this->render('full_post', ['model' => $model->find()->where(['slug' => $slug])->one(), 'action' => 'full']);
 }