I wanted to check if variable is there or not in blade ..for that i have used following lines:
@if(is_null($products))
<div class="alert alert-warning">
<strong>Sorry!</strong> No Product Found.
</div>
@else
@foreach($products as $product)
//
@endforeach
@endif
The problem is when there is $products on blade i could show inside of foreach loop but when i get empty variable.i couldn't show the message "No Data Found" instead it shows only empty space? is there any problem of checking variable inside of blade?
Controller code :
public function productSearch(Request $request)
{
$name = $request->name;
$products = Product::where('name' , 'like', '%'.$name.'%')->get();
return view('cart.product',compact('products'));
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qH9XnE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire