public function actionIndex() { $lastPosts = Post::find()->orderBy('created_at desc')->limit(10)->all(); $featured = Post::featured(); $drafts = Post::drafts(); $mostPopularCategory = Category::find()->joinWith('posts')->select('category.id, post.category_id, count(distinct post.title) as qty, category.title')->groupBy('post.category_id')->orderBy('qty desc')->one(); $mostPopularTag = Tag::find()->joinWith('posts')->select('tags.id, posts_tags.tag_id, count(distinct posts_tags.post_id) as qty, tags.title')->groupBy('posts_tags.tag_id')->orderBy('qty desc')->one(); $postsCount = Post::find()->where('active = 1')->count(); $categoryCount = Category::find()->count(); return $this->render('index', ['lastPosts' => $lastPosts, 'featured' => $featured, 'drafts' => $drafts, 'mostPopularCategory' => $mostPopularCategory, 'mostPopularTag' => $mostPopularTag, 'postsCount' => $postsCount, 'categoryCount' => $categoryCount]); }
public function actionIndex() { $slides = Slider::find()->all(); $featured = \common\models\Post::featured(12); return $this->render('index', ['slides' => $slides, 'featured' => $featured]); }