Example #1
0
 public function actionView($id = NULL)
 {
     if ($id === NULL) {
         throw new HttpException(404, 'Not Found');
     }
     $post = Posts::find()->where(['id' => $id])->one();
     if ($post === NULL) {
         throw new HttpException(404, 'Document Does Not Exist');
     }
     echo $this->render('view', array('post' => $post));
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'createdBy' => $this->createdBy]);
     $query->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'img_post', $this->img_post])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'small_description', $this->small_description])->andFilterWhere(['like', 'Description', $this->Description]);
     return $dataProvider;
 }