本文整理匯總了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'));
}