How to make a pagination for news category?

I can not understand how to make pagination of news category!

$category = Category::where('slug', $slug)->with(['articles' => function ($query) {
$query->paginate(5);
}])->firstOrFail();

In this case, arguing that there is no method links.. Tell me, how is that possible to do?
June 26th 19 at 14:01
1 answer
June 26th 19 at 14:03
Solution
$category = Category::where('slug', $slug)->firstOrFail();

$articles = $category->articles()->paginate(5);
Thank you and 1 query does not? - Domenick75 commented on June 26th 19 at 14:06
: You are inside the query database vizuete paginate(5) options which you have written is correct. - Peyton66 commented on June 26th 19 at 14:09
Exactly, thank you all - Domenick75 commented on June 26th 19 at 14:12

Find more questions by tags LaravelFrameworksWeb Development