Ejemplo n.º 1
0
 public function getCategory()
 {
     $post = Post::findOne($this->id);
     foreach (explode(',', $post->category_id) as $value) {
         $category = Category::findOne($value);
         if (!empty($category)) {
             $data[] = ['id' => $category->id, 'parent_id' => $category->parent_id, 'title' => $category->title, 'indent' => $this->getIndent($category->indent)];
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find()->where(['type' => 'news'])->orderBy('id DESC'), 'pagination' => ['pageSize' => 10]]);
     $this->view->title = 'News';
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }