How would I do a conditional laravel query taking in consideration what I try and did not work, where I try to get get products with a specifc name if name is not empty
This one is not working!!
public function getProducts($page = null, $match=null, $price = null) {
if ($page != null)
DB::getPaginator()->setCurrentPage($page);
$products = Product::join('product_specs', 'products.productid', '=', 'product_specs.product_id')
->join('feeds_categories', 'product_specs.category', '=', 'feeds_categories.id')
->where('feeds_categories.name', '=', 'Notebooks')
->where('products.status', '=', 1)
->where('products.price', '>', 250)
->orderBy('products.price', 'ASC')
->paginate(10);
if($match !='') $products->where('productname','LIKE','%'.$match.'%');
return $products;
}