/**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new PostSearch();
     $model = new Post();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'model' => $model]);
 }
Example #2
0
 /**
  * Get published posts
  * @return array|\yii\db\ActiveRecord[]
  */
 public function getPublishedPosts()
 {
     return PostSearch::find()->joinWith('category')->where(['publish_status' => Post::STATUS_PUBLISHED, 'blog_category.id' => $this->id])->all();
 }