Add username to register form

This commit is contained in:
Daniel Supernault 2018-04-15 18:23:02 -06:00
parent 40c2053314
commit d1b44529df
3 changed files with 17 additions and 1 deletions

View file

@ -50,6 +50,7 @@ class RegisterController extends Controller
{ {
return Validator::make($data, [ return Validator::make($data, [
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'username' => 'required|alpha_dash|min:2|max:15|unique:users',
'email' => 'required|string|email|max:255|unique:users', 'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed', 'password' => 'required|string|min:6|confirmed',
]); ]);
@ -65,6 +66,7 @@ class RegisterController extends Controller
{ {
return User::create([ return User::create([
'name' => $data['name'], 'name' => $data['name'],
'username' => $data['username'],
'email' => $data['email'], 'email' => $data['email'],
'password' => Hash::make($data['password']), 'password' => Hash::make($data['password']),
]); ]);

View file

@ -15,7 +15,7 @@ class User extends Authenticatable
* @var array * @var array
*/ */
protected $fillable = [ protected $fillable = [
'name', 'email', 'password', 'name', 'username', 'email', 'password',
]; ];
/** /**

View file

@ -25,6 +25,20 @@
</div> </div>
</div> </div>
<div class="form-group row">
<label for="username" class="col-md-4 col-form-label text-md-right">Username</label>
<div class="col-md-6">
<input id="username" type="text" class="form-control{{ $errors->has('username') ? ' is-invalid' : '' }}" name="username" value="{{ old('username') }}" required>
@if ($errors->has('username'))
<span class="invalid-feedback">
<strong>{{ $errors->first('username') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>