I'm using Laravel 5.2 and I'm trying to create a validation for user registration.
In UserController.php I have:
public function postSignUp(Request $request){
$this->validate($request, [
'email' => 'required|email|unique:users',
'first_name' => 'required|max:120',
'password' => 'required|min:4'
]);
...
}
And in the View for SignUp I have:
@if(count($errors) > 0)
<div class="row">
<div class="col-md-6">
<ul>
@foreach($errors->all as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
But when you try to register a user with an existing email or even put no text in the inputs, the div .col-md-6 is created but does not return anything.
I gave a var_dump in $ errors and this appears:
object(Illuminate\Support\ViewErrorBag)[133]
protected 'bags' =>
array (size=1)
'default' =>
object(Illuminate\Support\MessageBag)[134]
protected 'messages' =>
array (size=3)
...
protected 'format' => string ':message' (length=8)