I'm currently using the laarvel5.4 authentication in my application; and I want to change the users table name while keeping its role as it is in the authentication logic, all I need is just to change the name.
It seems that Laravel changer the Auth file and code structure in the latest version, so auth.php doesn't really look as in the previous versions of laravel.
I have done the following so far, but it's still not working gy giving me an error saying that the table users doesn't exist:
- 1- I have changed the migration's up() and down() functions to create and drop staff table instead of users and run the migration successfully.
2- I have changed the validator() function in RegisterController.
3- I have changed all the 'users' to 'staff' in config/auth.php, as shown in the code:
return [ 'defaults' => [ 'guard' => 'web', 'passwords' => 'staff', ], 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'staff', ], 'api' => [ 'driver' => 'token', 'provider' => 'staff', ], ], 'providers' => [ 'staff' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], // 'staff' => [ // 'driver' => 'database', // 'table' => 'staff', // ], ], 'passwords' => [ 'staff' => [ 'provider' => 'staff', 'table' => 'password_resets', 'expire' => 60, ], ],
];
However, in app/User.php I don't know what to change since in the previous versions there used to be a table variable which u need to change its value from users to the new table name but in my class I don't have such thing
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}