本文整理匯總了PHP中common\models\Post::drafts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Post::drafts方法的具體用法?PHP Post::drafts怎麽用?PHP Post::drafts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\Post
的用法示例。
在下文中一共展示了Post::drafts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionIndex
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]);
}