I have a piece of code like this:
$products = Product::all() if ($search_value) { $products = $products->where(\'name\', \'LIKE\', \"%$search_value%\
just use the one line code it will work fine
$product= Product::orderBy('created_at','desc')->get();