/**
  * Finds the Comment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Comment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Comment::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comment::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'content_id' => $this->content_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'reply_ids', $this->reply_ids])->andFilterWhere(['like', 'user_name', $this->user_name])->andFilterWhere(['like', 'user_email', $this->user_email])->andFilterWhere(['like', 'user_url', $this->user_url])->andFilterWhere(['like', 'user_ip', $this->user_ip])->andFilterWhere(['like', 'user_address', $this->user_address])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }