2
I am using Laravel 5.2 and am trying to create a validation for user record.
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 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 trying to register a user with existing email or even without putting any text in the inputs, the div .col-Md-6 is created but returns nothing.
I var_dump $errors and this comes up:
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)
Really, Voce is correct ! It was a syntax error that went unnoticed. In case missing the parentheses after all. Thank you very much !
– Flaviano Astolfo