<?
$products = Product::where(function ( $q ) use ( $request ) {
if ( $request->category ) {
$q->where('category_id', $request->category);
}
if ( $request->status ) {
$q->where('status', $request->status);
}
$q->where('type', $request->type);
})->get();
return $products;