foreach empty laravel code example
Example 1: foreach empty laravel
@forelse($status->replies as $reply)
{{ $reply->body }}
@empty
No replies
@endforelse
Check the documentation for the best result:
http://laravel.com/docs/5.1/blade#control-structures
Example 2: Laravel Blade Foreach If Empty or Not
public function index()
{
$products = Product::get();
return view('home',compact('products'));
}
Laravel Check Array Empty in Blade
@forelse ($products as $product)
product
@empty
No product
@endforelse