public function index(Channel $channel)
{
if ($channel->exists) {
$brands = $channel->brands()->latest()->get();
} else {
$brands = Brand::latest()->get();
}
return view('brands.index', compact('brands'));
}
This does work except when I try to add pagination. Then it only shows first foreach and never makes it to the second or third. I am guessing there is a better way to do category sections on my index page.
Yeah I see this, but I am still having issues with the pagination. If I say paginate(4) because I only want each category section to show 4 brands on the index page this solution doesn't work. I only see the first 4 posts with the channel_id ==1. I am looking for a way to show 4 brands for each category on the first page.