I am learning laravel and I am still at beginner level. I have used php artisan make:auth through which I have created the authentication code.
I have tried to add extra address field while registration. But while entering the details it is still showing that the address field is empty.
I want suggestions on how to remove the error
Thank you for your support
RegisterController.php
I have added also the address field in RegisterController.php
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'address' => ['required', 'text', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'username' => ['required', 'string', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:6', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'address' => $data['address'],
'email' => $data['email'],
'username' => $data['username'],
'password' => Hash::make($data['password']),
]);
}
register.blade.php
I have added also the address field in register.blade.php
<div class="form-group row">
<label for="address" class="col-md-4 col-form-label text-md-right">{{ __('address') }}</label>
<div class="col-md-6">
<input id="address" type="text" class="form-control{{ $errors->has('address') ? ' is-invalid' : '' }}" address="address" value="{{ old('address') }}" required autofocus>
@if ($errors->has('address'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('address') }}</strong>
</span>
@endif
</div>
</div>
User.php:
I have added also the address field in User.php
protected $fillable = [
'name', 'email','username','address', 'password',
];