Пример #1
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 return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'user_id', $this->user_id])->andFilterWhere(['like', 'post_id', $this->post_id])->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'created_at', $this->created_at]);
     return $dataProvider;
 }
Пример #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 return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'waktu' => $this->waktu, 'post_id' => $this->post_id]);
     $query->andFilterWhere(['like', 'nama', $this->nama])->andFilterWhere(['like', 'isi', $this->isi]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comment::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Displays a single Post model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     Yii::$app->session['post_id'] = $id;
     $querykomen = Comment::find()->where(['post_id' => $id]);
     $hitungkomen = clone $querykomen;
     $page = new Pagination(['totalCount' => $hitungkomen->count()]);
     $komen = $querykomen->offset($page->offset)->limit($page->limit)->all();
     $namaKomen = "";
     foreach ($komen as $komens) {
         $namaKomen = $komens->nama;
     }
     $nama = $this->findModel($id)->nama;
     $usr = new \common\models\User();
     $fotoPost = $usr->find()->where(['nama' => $nama])->all();
     $fotoKomen = $usr->find()->where(['nama' => $namaKomen])->all();
     return $this->render('view', ['model' => $this->findModel($id), 'komen' => $komen, 'fotoPost' => $fotoPost, 'fotoKomen' => $fotoKomen, 'page' => $page]);
 }
Пример #5
0
 /**
  * Displays a single Post model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = Post::find()->where(['id' => $id])->one();
     $model->views++;
     $model->save();
     $com = Comment::find()->all();
     Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $model->description]);
     Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => $model->seo_keywords]);
     $model_com = new Comment();
     if ($model_com->load(Yii::$app->request->post()) && $model_com->save()) {
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         /*return $this->render('create', [
               'model' => $model,
           ]);*/
     }
     return $this->render('view', ['model' => $this->findModel($id), 'com' => $com, 'model_com' => $model_com]);
 }
 /**
  * Displays page where one can edit comment chosen by id
  * @param $id
  * @return string
  */
 public function actionEdit($id)
 {
     $id = Yii::$app->request->get('id');
     // Checking if line with this id exists
     $check_id = Comment::find()->select(['comment_writer'])->where(['comment_id' => $id])->one();
     if ($check_id != null) {
         $comment = new Comment();
         $comment_to_update = $comment->findModel($id);
         $commentForm = new CommentUpdateForm($id, $comment_to_update);
         if ($commentForm->load(Yii::$app->request->post()) && $commentForm->updateComment($id)) {
             Yii::$app->session->setFlash('messageUpdated');
             $this->redirect(Yii::$app->getUrlManager()->createUrl('comment/view'));
         } else {
             return $this->render('edit', ['commentForm' => $commentForm]);
         }
     } else {
         $this->redirect(Yii::$app->getUrlManager()->createUrl('comment/view'));
     }
 }
Пример #7
0
 /**
  * Gets model to further update
  * @param $id
  * @return array|null|ActiveRecord
  */
 public function findModel($id)
 {
     return $comment = Comment::find()->where(['comment_id' => $id])->asArray()->one();
 }
Пример #8
0
 public function findByIdCom($orderDetailId)
 {
     $comment = Comment::find()->where(['typeId' => $orderDetailId])->one();
     if (!$comment) {
         return false;
     }
     return $comment;
 }
Пример #9
0
 /**
  * @inheritdoc
  */
 public function getAllComment()
 {
     $comments = Comment::find();
     return $comments;
 }