Hey all I am attempting to construct person administration system in laravel 7, However in my registration kind I am preserve getting a validation error for my cellular quantity enter.
That is my registration kind
<kind technique="POST" motion="{{ route('register') }}">
@csrf
<div class="form-group row">
<label for="identify" class="col-md-Four col-form-label text-md-right">{{ __('Identify') }}</label>
<div class="col-md-6">
<enter id="identify" sort="textual content" class="form-control @error('identify') is-invalid @enderror" identify="identify" worth="{{ outdated('identify') }}" required autocomplete="identify" autofocus>
@error('identify')
<span class="invalid-feedback" position="alert">
<sturdy>{{ $message }}</sturdy>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="user_type" class="col-md-Four col-form-label text-md-right">{{ __('You Are a') }}</label>
<div class="col-md-6">
<choose id="user_type" class="form-control @error('user_type') is-invalid @enderror" identify="user_type">
<choice worth="">-Choose your type-</choice>
<choice worth="Store Proprietor">Store Proprietor</choice>
<choice worth="Buyer">Buyer</choice>
</choose>
@error('user_type')
<span class="invalid-feedback" position="alert">
<sturdy>{{ $message }}</sturdy>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="electronic mail" class="col-md-Four col-form-label text-md-right">{{ __('E-Mail Handle') }}</label>
<div class="col-md-6">
<enter id="electronic mail" sort="electronic mail" class="form-control @error('electronic mail') is-invalid @enderror" identify="electronic mail" worth="{{ outdated('electronic mail') }}" required autocomplete="electronic mail">
@error('electronic mail')
<span class="invalid-feedback" position="alert">
<sturdy>{{ $message }}</sturdy>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="electronic mail" class="col-md-Four col-form-label text-md-right">{{ __('Cellular Quantity') }}</label>
<div class="col-md-6">
<enter id="cellular" sort="textual content" class="form-control @error('cellular') is-invalid @enderror" identify="cellular" worth="{{ outdated('cellular') }}" required autocomplete="electronic mail">
@error('cellular')
<span class="invalid-feedback" position="alert">
<sturdy>{{ $message }}</sturdy>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-Four col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<enter id="password" sort="password" class="form-control @error('password') is-invalid @enderror" identify="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" position="alert">
<sturdy>{{ $message }}</sturdy>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-Four col-form-label text-md-right">{{ __('Affirm Password') }}</label>
<div class="col-md-6">
<enter id="password-confirm" sort="password" class="form-control" identify="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button sort="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>
</div>
</kind>
And that is my controller
protected operate validator(array $information)
{
return Validator::make($information, [
'name' => ['required', 'string', 'max:255'],
'electronic mail' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'cellular'=>['required','numeric', 'min:10','max:12'],
'user_type'=>['required','string'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a brand new person occasion after a sound registration.
*
* @param array $information
* @return AppUser
*/
protected operate create(array $information)
{
return Person::create([
'name' => $data['name'],
'electronic mail' => $information['email'],
'cellular'=>$information['mobile'],
'user_type'=>$information['user_type'],
'password' => Hash::make($information['password']),
]);
}
The problem is now I’ve validated my cellular quantity subject for max of 12 characters solely
'cellular'=>['required','numeric', 'min:10','max:12'],
However once I run my code each time I am getting an validation error message saying,
"The cellular will not be larger than 12."
My enter was, 0774566678
What was the problem?