D
D
darksladen2017-05-11 11:19:35
Laravel
darksladen, 2017-05-11 11:19:35

How to make pagination for category news?

I don’t understand how to properly paginate news in a category!
$category = Category::where('slug', $slug)->with(['articles' => function ($query) {
$query->paginate(5);
}])->firstOrFail();
In this case, it swears that there is no links method .. Tell me, how can this be done at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WebDev, 2017-05-11
@darksladen

$category = Category::where('slug', $slug)->firstOrFail();

$articles = $category->articles()->paginate(5);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question