I don't know if I correctly formulated the question. However, I've got 2 tables - products and categories (many to many relationship) and in categories page I want to display it's products with pagination if it has any and if it doesn't - I want to display "products not found". It worked, but without pagination.
Here's the controller:
public function show($slug)
{
$category = $this->categoryRepository->findBySlug($slug);
$paginate = $category->products()->paginate(6);
return view('site.pages.category')->with(['category' => $category,
'paginate' => $paginate]);
}
What to do achieve this?