简体   繁体   中英

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?

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 :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM