vendredi 15 février 2019

Laravel 5.4 display errors in view

I have a form where I upload a file. In the controller I do all kinds of checks on columns in this file and get some errors.

I add these errors to an array and I want to display all these errors in the view.

I tried all kinds of solution but nothing works.

Right now, I'm doing this in the controller for each line in the file:

$errors[] = array('file_name'=>$file_name, 'error'=>'Invalid coffee name');

And in the view I try these two things:

@if ($errors->any())
    
@endif

@if ($errors->any())
 @foreach ($errors->all() as $error)
     <div></div>
 @endforeach
@endif

The problem is, although I have 2 errors in the errors array (I checked), I only see the last one in the view.

What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire