santigarcor / laratrust

Handle roles and permissions in your Laravel application
MIT License
2.19k stars 374 forks source link

Multiple Team types #486

Closed abcmoritz closed 1 year ago

abcmoritz commented 3 years ago

Hello, im a little bit confused how i would handle multiple team types. (Maybe its a dumb questions and i just need sleep)

Lets say i have a sport team with a data set which includes the name, description, location ... and multiple members with multiple roles like player, trainer and supervisor. But i also have a team for organizing tournaments.

Both teams have different kinds of data and relationships. Would i create a SportTeamData and TournamentTeamData Model and connect them to the laratrust team model?

Or am i completly wrong? What would be the best way to handle this?

filippotoso commented 1 year ago

You can use the default Team model provided by Laratrust and create a one-to-one polymorphic relation with the SportTeam and TournamentTeam models and leave the properties and relationships in the respective models.

Otherwise you can try with the approach suggested by Caleb Porzio here (a kind of model inheritance). Mostly depends on how much custom fields are needed in the Team model to support both your types of teams.