DEV Community

SidneyMachara
SidneyMachara

Posted on

multiple user types ( laravel )

Top comments (5)

Collapse
 
sidneymachara profile image
SidneyMachara

i am planning out a school management system, the main actors are ( Teachers ,Students , Parent ).

i though i will simply have

User Model -> will have attributes common to ( Teachers ,Students , Parent ).
Teacher Model -> will have user_id and teacher specific attributes.

Student Model -> will have user_id and student specific attributes

Parent Model -> will have user_id and parent specific attributes

Now i realised that a single user can have multiple roles ,example a Teacher can also be a parent ,this brings up the question of which dashboard to direct them to when they login, how to control / manage their different permissions between the accounts and so forth.

my initial solution was to prompt the any user with multiple roles which account they want to use upon login.

How would you guys tackle this ?????????? whats the best way ...
Collapse
 
sebastiangperez profile image
Sebastiangperez • Edited

Do you gonna have some kind of Frontend login for parents and students and a backend for teachers?
Maybe you can use multiple guards and auth instances so you can split the login and tables, i mean, one for users whith user_roles parent / student and another for admins admin_roles (general admin / Teachers)

Collapse
 
sidneymachara profile image
SidneyMachara • Edited

thats a nice approach but i was hoping to avoided having extra guard and also avoid polymorphic relationships later on.

thanks for feedback

Thread Thread
 
sebastiangperez profile image
Sebastiangperez
Thread Thread
 
sidneymachara profile image
SidneyMachara

thanks ..will look into it