So you don't know that a given User is a admin, trainer or student without querying each of the _profiles tables for a matching user_id????
Oct 6, 2022
2
Level 63
Class inheritance and multiple tables
Hello,
I have several roles (admin, collaborator, trainer, student, ...) and each one has some common properties, but also some different properties.
Here are an example of tables I'd like to create.
- users: id, name
- admin_profiles: id, user_id, ...
- trainer_profiles: id, user_id, ...
- student_profiles: id, user_id, ...
What could be fine would be to write a User model and other models Trainer, Student, ... which inherit from the User model.
So when I need to retrieve trainers, I need to query the trainer_profiles table and the users table.
But I really don't see how it is possible with Laravel because the properties are in different tables.
If it's possible to do that, how can I do that ?
Thanks for your help.
Vincent
Please or to participate in this conversation.