We use a model like UserRoles as a type of relationship for something like that. This way you can expand on the roles and have multiple roles per user.
User model best practices
I'm starting a new Laravel 5.8 application and using the built-in Laravel auth.
I know that you can rename the default User model and change the database table name. My question is if that is advisable and if that will make upgrading my Laravel application more difficult as new Laravel versions are released.
For example - If my application has users who are firefighters, it makes more semantic sense in my code to have properties and methods such as firefighter->schedule() or firefighter->name or firefighter->assignedTruck .
Would I be better off just sticking with the default User model, renaming the User model, or creating a "hasOne" eloquent relationship between the User model and a Firefighter model?
You could perhaps stick with the User model, and use it for authentication, but then create a Firefighter model which extends User.
It does not need to contain any functionality if you don't want, but it could contain relationships etc.
eg;
<?php
namespace App;
use App\User;
class Firefighter extends User
{
public $table='users';
}
Please or to participate in this conversation.