Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comments::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'table_id' => $this->table_id, 'parent' => $this->parent, 'parent_id' => $this->parent_id, 'createdby' => $this->createdby, 'createdon' => $this->createdon, 'rate' => $this->rate, 'rate_num' => $this->rate_num, 'like' => $this->like, 'dislike' => $this->dislike, 'status' => $this->status, 'deleted' => $this->deleted, 'deletedby' => $this->deletedby, 'deletedon' => $this->deletedon, 'editedby' => $this->editedby, 'editedon' => $this->editedon]);
     $query->andFilterWhere(['like', 'table_name', $this->table_name])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'introtext', $this->introtext])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
 /**
  * Finds the Comments model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Comments the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Comments::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }