本文整理汇总了PHP中app\Category::articles方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::articles方法的具体用法?PHP Category::articles怎么用?PHP Category::articles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::articles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the category articles
*
* @param Category $category
* @return Response
*/
public function index(Category $category)
{
$articles = $category->articles()->published()->orderBy('published_at', 'desc')->paginate(5);
return view('application.category.index', compact('articles', 'category'));
}
示例2: getPostAvaiable
public static function getPostAvaiable(Category $category)
{
return $category->articles()->where('status', 1)->paginate(5);
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show(Category $category)
{
$articles = $category->articles()->latest('published_at')->published()->get();
return view('admin.articles.index', compact('articles'));
}
示例4: listArticles
/**
* Hiển thị thông tin bài viết theo category
*
* @param Category $category
* @return Response
*/
public function listArticles(Category $category)
{
$articles = $category->articles()->active()->orderBy('published_at', 'desc')->paginate(config('blog.record_per_page'));
return view('categories.list_articles', compact('category', 'articles'));
}