Example #1
0
 public function run()
 {
     if ($this->id == 0) {
         return;
     }
     $model = new BlogComments();
     $comments = BlogComments::find()->orderBy('date_gmt ' . $this->orderDirection)->where('post_id = :id', ['id' => $this->id])->all();
     return $this->render('comment', ['model' => $model, 'comments' => $comments, 'id' => $this->id]);
 }
 public function search($params)
 {
     $query = BlogCommentsModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'post_id' => $this->post_id, 'parent' => $this->parent, 'notify_reply' => $this->notify_reply, 'notify_comments' => $this->notify_comments, 'date' => $this->date, 'date_gmt' => $this->date_gmt]);
     $query->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'approved', $this->approved])->andFilterWhere(['like', 'author_name', $this->author_name])->andFilterWhere(['like', 'author_email', $this->author_email])->andFilterWhere(['like', 'author_url', $this->author_url])->andFilterWhere(['like', 'author_ip', $this->author_ip]);
     return $dataProvider;
 }
 /**
  * Finds the BlogComments model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BlogComments the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BlogComments::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBlogComments()
 {
     return $this->hasMany(BlogComments::className(), ['post_id' => 'id']);
 }