Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Karim_Taha's avatar

Laravel Authentication using different model rather than the user model

I have a Customer model that I want to use as an Authentication system: (Laravel 11) but I get: Illuminate\Auth\SessionGuard::login(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Authenticatable, App\Models\Customer given, called in C:\xampp\htdocs\Projects\testproject\app\Http\Controllers\AuthController.php on line 86

Customer model:

0 likes
9 replies
Tray2's avatar

Why would you wanna do that?

If you have another table where you store your users, the easiest would be to just change the table property in your user model.

protected $table = 'customers';
Karim_Taha's avatar

@Tray2 I already use users table, I just need to separate the customers from users table

Tray2's avatar

@Karim_Taha A user, is a user, you should use roles to distinguish between them, not adding additional tables for the same thing.

Karim_Taha's avatar

@martinbean The customers table has many columns and if I used the users table and when the role, for example, is not a customer there will be a lot of null data and I don't want that

Tray2's avatar
Tray2
Best Answer
Level 73

@Karim_Taha It's all very simple, a user is a user, and a customer is a user, the user is for authentication, then you have roles to determine what kind of user it is, and what it has access to. The customers table contains customer information about a user, and it has a user_id to determine which user the customer info belongas to.

Don't try to implement different tables to authenticate against, harness the power of the relational database instead.

jaseofspades88's avatar

Customer needs to implement the Authenticatable contract (and implement the subsequent methods). I would however recommend you just use the User model and introduce a role or a column on the user to differentiate the users. It would save you any headaches

Please or to participate in this conversation.