I'm using Laravel 5.3 and used the make:auth
artisan command to scaffold the login/registration system. I'm doing my login as companies, so I have a table called Company
. How do I change the original sql to go get the email and password from the Company
table instead of the User
table?
I already tried to change in the config/auth.php
file in the providers part, but when I changed 'model' => App\User::class,
to 'model' => App\Company::class,
, it started logging in, but regardless if the email and password input were completely wrong. Any ideas?
EDIT: After the Company
registers and logs in, it has the ability to invite Users
, therefore the original User
table has to remain
DO NOT FORGET TO CHANGE VALIDATION IN REGISTERCONTOLLER.PHP AS WELL.
from
to
Laravel 5.3 has changes in the Auth implementation. For me, this way solved it:
First, provide a company table in the database that fulfils the criteria to be used for identification. Thus, it needs a name, email, password and remember_token column. Details can be found here.
In the config/auth.php change the users model to your company class.
Create a Company class in the App folder that extends the Auth, so use:
In the Company class, define fillable and hidden fields.
In the RegisterController.php change "use App\User" to
Adjust the create and validator function in the RegisterController.php with Company::create
'email' => 'required|email|max:255|unique:companies'
(table name for Company Model will be companies)
Hope this helps!