Skip to content

Instantly share code, notes, and snippets.

@samcrosoft
Created March 2, 2015 12:08
Show Gist options
  • Save samcrosoft/1cb6d441782864dbe207 to your computer and use it in GitHub Desktop.
Save samcrosoft/1cb6d441782864dbe207 to your computer and use it in GitHub Desktop.
A quick snippet to use a condition to bind the display of all errors in a laravel blade view
@if($errors->has())
@foreach ($errors->all() as $error)
<p class="error">{!! $error !!}</p>
@endforeach
@endif
@massiws
Copy link

massiws commented Sep 21, 2017

In Laravel 5.5 with PHP 7.* I get this error:

Missing argument 1 for Illuminate\Support\MessageBag::has(), called in ~/vendor/laravel/framework/src/Illuminate/Support/ViewErrorBag.php on line 95

You must pass an empty array in has() function:

@if($errors->has([]))
    @foreach ($errors->all() as $error)
        <p class="error">{!! $error !!}</p>
    @endforeach
@endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment