Level 19
$brandIds = Request::all();
$products = Product::whereHas('brands', function($query) use ($brandIds) {
$query->whereIn('brand_id', $brandIds);
})->paginate(1);
// make path
$path = 'catalog?';
foreach ($brandIds['brand_id'] as $id) {
$path .= 'brand_id[]=' . $id . '&';
}
$products->setPath($path);
return $products;