Change users tablename
Hi to all,
In version 5.1 If I want to change the name of users to any name, what rework or what file/s do I also need to make changes?
In config/auth.php i change this line:
'table' => 'users',
But I think changing that one is not enough since I can't retrieve the authenticated user using this facade, $user = Auth::user();
Thank you.
Also you need to change model in the same file
'model' => 'App\Models\User', //whatever here
and in the model itself
verify protected $table property and its value
Sorry but i'm still new to laravel and did not quite get what you mean. I can see this on the same file
'model' => App\User::class,
what do you mean change whatever here?
Thank you.
@gvauditor within your app/User.php class, add the following protected property:
protected $table = 'whatever';
@gvauditor
Where is your User class ? what is name space of it?
Make sure following::
if your database table name is 'users' and class name is 'User' then no need to add any protected $table property in 'User' model
in auth.config
you have to set correct $model and $table where $model should be with proper namepaced
Thanks everyone guys, I needed to add that line in the app/User.php for it to work.
i changed auth table, and registration was successfull, but i can not login after logout
Please or to participate in this conversation.