/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SptComment::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, 'task_id' => $this->task_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
 /**
  * Displays a single SptTask model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if (isset($_POST['progress'])) {
         $model->progress = $_POST['progress'];
         $model->save();
         \Yii::$app->session->setFlash('success', 'Save progress success');
     }
     $comment = new \ivoglent\simpletask\models\SptComment(['task_id' => $model->id, 'user_id' => \Yii::$app->user->identity->id]);
     if ($comment->load(\Yii::$app->request->post())) {
         if ($comment->save()) {
             \Yii::$app->session->setFlash('success', 'Comment success');
         } else {
             print_r($model->getErrors());
         }
     }
     $commentProvider = new ActiveDataProvider(['query' => SptComment::find()->where(['task_id' => $id])]);
     return $this->render('view', ['model' => $model, 'commentProvider' => $commentProvider, 'comment' => $comment]);
 }