Artek
Artek

Reputation: 57

How can I get information about errors in laravel 6.0?

When I used Laravel 5.8 I could get information about errors like this :

@if(count($errors > 0))
     <ul class="error-list" >
         @foreach($errors->all() as $error)
           <li class="error-list-element">{{$error}}</li>
         @endforeach
    </ul>  
@endif

It worked completly fine. Since Laravel 6.0 was released the code above results in error :

Object of class Illuminate\Support\ViewErrorBag could not be converted to int

So how can I get information about errors in Laravel 6.0?

Upvotes: 1

Views: 121

Answers (2)

Ahmad Abo Zaid
Ahmad Abo Zaid

Reputation: 340

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

Upvotes: 1

Gulshan S
Gulshan S

Reputation: 1104

Here is code :

 @if ($errors->any())
      <div class="alert alert-danger">
          <ul>
              @foreach ($errors->all() as $error)
                  <li>{{ $error }}</li>
              @endforeach
          </ul>
      </div>
  @endif 

Hope this will help :)

Upvotes: 2

Related Questions