So I changed the users table to members in a laravel 5 application. I also changed the config/Auth file to represent that. However when I try to register a user it gives me the error that's it's looking for "Database.users".
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'task_manager.users' doesn't exist (SQL: select count(*) as aggregate from `users` where `username` = rodzzlessa)
/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'users',
Need to have "database" set as the driver for that to come into effect?
If you only change the table in that file, it won't do anything. You need to set it to "database" instead of "eloquent". But I think you want eloquent so changing the "model" part is right. The comments state that.
You need to search for 'unique:users' in 'app/Services/Registrar.php' and replace the users part with your table name 'members' => 'unique:members'
Let me explain. The error that you are getting is with validator function which needs to validate emails as unique entity. Since the Validator class does not know from which table to validate the entered email id, we need to pass the table name 'users' which is by default or 'members' as in your case.
Also make sure to do following changes
config/Auth:- 'table' => 'members',
app/User.php:-
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
use Authenticatable, CanResetPassword;
/** ----------- Add this line in -----------
* The database table used by the model for authentication.
*
* @var string
*/
protected $table = 'members';
Found this after posting to a thread on extending Sentinel and have tried all the above with no success.
Also found that registering a new user has the same error regarding no users table.
I have installed the latest Sentinel which comes with 5.1
Is it possible that 5.2 works with the above?
A note for other people:
I actually created a new model Member.
This required:
in AuthController -> validator(array $data)
'email' => 'required|email|max:255|unique:members'
in AuthController -> create(array $data)
return Member::create([ ...
But actually, it takes quite a lot of tweaks to make entire login/register/password reminder for multiple users, if you want to keep Laravel native auth and all.