Reputation: 803
Please bear with me I'm new to Laravel.
if I leave the code below out... my form validation seems fine.
@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 as soon as I add the above code it Fails and gives me the error :
Use of undefined constant errors - assumed 'errors'
I have the route under this middleware
Route::group(['middleware' => ['web']], function(){
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);
}
because I have it under that middleware its supposed to have the error constant.
I cant find anything regarding this problem with the display errors. please can someone tell me what I'm doing wrong?
Upvotes: 0
Views: 3975
Reputation: 16
$errors
is a variable whilst errors
is just a normal word without any reference or meaning to the code editor or programme.
@if(count(errors) > 0)
In this line, write instead @if(count($errors) > 0)
, just as same as this line:
@foreach($errors->all() as $error)
Afterwards, the error will go away and the code will work just fine.
Upvotes: 0
Reputation: 35357
$errors != errors
One is a variable, one is a constant, note the missing $
.
The error bag would not be a constant since constant values never change, be sure to better familiarize yourself with php types and syntax before even attempting to use Laravel.
Upvotes: 2