I'm getting a problem printing $errors on Blade view. I was using validator on controller/model and everything was ok, the blade could print $errors. But now i want to migrate that validation to Form requests.
If i use json/ajax (application/json) everything works fine, all errors came in response. But when i use form-data (multipart/form-data) the $errors variable is always empty.
What am i missing? Here's some code:
View:
{{ Form::open(['url' => 'foo','files' => true, 'name'=>'foo-form']) }}
//some inputs
{{Form::close()}}
Form Request:
public function authorize()
{
return true;
}
public function rules()
{
return [
"id" => "required|exists:foo,id",
"begin_date" => "required|date",
"end_date" => "required|date|after:begin_date"
];
}
[EDIT]
I've already tried many ways to display my errors:
-the official way: https://laravel.com/docs/5.4/validation#quick-displaying-the-validation-errors
-With var_dump and dd
-My way (that work with validator on model/controller):
@if(Session::has('errors'))
<div class="alert alert-danger alert_header">
@foreach(Session::get('errors') as $error)
<p>{{ $error }}</p>
@endforeach
</div>
@endif
I've already tested with browser (chrome) and postman too
[EDIT]
Controller:
public function uploadFoo(StoreUploadFoo $request)
{
return "Foo without errors";
}
Laravel version: 5.4