How to rename users DB table in default Laravel Auth

Replace users with your required table in following files

1. Migration file

2. Change the table in app/User.php

3. Change the table in config/auth.php

‘providers’ => [ ‘users’ => [ ‘driver’ => ‘eloquent’, ‘model’ => App\User::class, ],],

4. Validation rule – unique email check

In default app/Http/Controllers/Auth/AuthController.php there are validation rules listed. One of them states that email has to be unique – so we need to change the table it is checking: protected function validator(array $data) { return Validator::make($data,[ ‘name’ => ‘required|max:255′, ’email’ => ‘required|email|max:255|unique:users’, ‘password’ => ‘required|confirmed|min:6’, ]); } Change the part ‘unique:users’ to ‘unique:admins’.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *