Level 70
Have you tried this?
$category->products()->paginate(12);
Ofcourse there are some other ways to figure it out.
1 like
Hi,
I am having issue in getting all products by category slug in category single page the products data is fine but i need it with pagination to only show 12 on one page here is the below code i write.
Note: product and category have many to many relationship
$category = Category::where('slug', '=', $slug)->firstOrFail();
$categoryProducts = $category->products->paginate(12);
the above is works fine for me to get category all products but i need it with pagination any help please.
Regards
Please or to participate in this conversation.