Hello @corvs - is there any specific reason? I'm developing a mult-tenant application and after much consideration, I've concluded that it's better to have two different models.
For example, the Teacher model will have all the column supported by Laravel Cashier; while students model will have different set of columns.
Also, I'll need multiple unique columns on student and teacher model. That's the reason I was thinking of using two different models.
@thebigk Two different models for teachers and students are completely fine, but use the User model for authentication and a user can be a teacher or student then (or both).
@snapey - that will never be the case. I just stumbled upon the following block in config/auth.php -
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
Though I'm thinking of switching to just User model; I'm curious to know if the above block actually does what I'm trying to do.
You're reaching for the wrong tool here, tbh. What you need is Multi-Table Inheritance. You can read the README of this repo and if you have more questions, feel free to ask.