1 year ago

Paginate Eager Loaded Relationship

Posted 1 year ago by elliotk


I am trying to get pagination working for Products here. Where I have the paginate(6) at the moment, the correct number of Products are returned, although I don't know if it's the correct place to put it.

However, I have tried all sorts to get the links() to show in blade, and I can't figure it out.

Is there a special way with Eager Loaded relations?

class CategoryController extends Controller
    public function view(Category $category)
        $category->load(['products' => function ($products) {

        return view('shop.category.index', compact('category'));

Please sign in or create an account to participate in this conversation.