0
Hello! I’ve tried several times and I’m having difficulty visualizing the data of a Json in a View.
I’m passing this data like this in Controller:
$validatorES = new EntradaSaidaFormRequest();
if(!$validatorES->validar($request)){
   $errors = $validatorES->messages();    
   return $this->index()->with(compact('errors'));
}
Na View:
<div class="container col-sm-9">
    @if (!$errors->isEmpty())
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">×</span>
        </button>
        <ul>            
            @foreach ($errors as $error)
            {{ $error }}
            @endforeach 
        </ul>
    </div>
    @endif
</div>
My $errors variable is like this:
HTTP/1.0 400 Bad Request Cache-Control: no-cache, private Content-Type: application/json Date: Tue, 14 Jan 2020 13:53:30 GMT {"errors":{"descricao":["The descricao field is required."],"registro":["The registro field is required."]}}
But, I cannot print this variable in the View with Foreach above. I am getting the following error as return:
htmlspecialchars() expects parameter 1 to be string, array given 
						
Your solution is very valid but, I followed a different path because I did not do it the way I should. I used a single Controller to make Insert in two different tables which made things a little difficult (lesson for the next implementations).
– keniaferreira