inheritance of models

Posted 9 months ago by davfg

Hello, I have a problem when designing my models related to users and their relationships. In my application, I have three types of users: Admin, Manager and team of competitors. The models that I have thought to create so far are:

  • User (parent model): id, name, identifier, password, role_id (refer to a table Roles with three entries: admin, manager, team of competitors), competition_id (reference to a table Competitions).
  • Team: id, school, teacher, email, user_id (reference to the user table)
  • Competitor: id, name, birthday, educationalDegree, team_id (reference to the user table).

It should be mentioned that the attribute "competition_id" in the user table refers to a team of competitors participating in a certain competition, a manager can configure a single competition and an administrator can configure all competitions (set to null for admin) .

My problem arises when I want to relate these models to each other, where I have read that it can be done with polymorphic relationships, but I am not sure about it. I would appreciate any help regarding a new way of designing these models and their relationships or how to design relationships between these models.

Thank you very much for your time.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.