本文整理汇总了PHP中common\models\Post::featured方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::featured方法的具体用法?PHP Post::featured怎么用?PHP Post::featured使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Post
的用法示例。
在下文中一共展示了Post::featured方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
示例2: actionIndex
public function actionIndex()
{
$slides = Slider::find()->all();
$featured = \common\models\Post::featured(12);
return $this->render('index', ['slides' => $slides, 'featured' => $featured]);
}