/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PostSick::find();
     $query->joinWith(['sick', 'statusgroup']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['sick'] = ['asc' => ['specialist_sick.name_sick' => SORT_ASC], 'desc' => ['specialist_sick.name_sick' => SORT_DESC]];
     $dataProvider->sort->attributes['statusgroup'] = ['asc' => ['status.name' => SORT_ASC], 'desc' => ['status.name' => SORT_DESC]];
     $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_post' => $this->id_post, 'id_sick' => $this->id_sick, 'create_day' => $this->create_day, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name_post', $this->name_post])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'specialist_sick.name_sick', $this->sick])->andFilterWhere(['like', 'status.name', $this->statusgroup]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPostSicks()
 {
     return $this->hasMany(PostSick::className(), ['id_sick' => 'id_sick']);
 }
 /**
  * Finds the PostSick model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PostSick the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PostSick::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }