laratrust
laratrust copied to clipboard
Custom team column
I have a use case where I need to assign the office/location
to the team
. That means that I need to have an officeId
column/foreign key in the team
table and model. What is the proper way to add an additional column/foreign key
to the team
table/model?
I have modified the Team model to include a one-to-one polymorphic relationship called "context" then I bind the teams to their pertinent context. Every team has a host model responsible for it via the "context" relationship (and the inverse "team" from the host model).
A part from what Greg suggested, depending on the size of the project and how much abstractions one needs, sometimes I just add the field to the teams table and customize the models to fit my needs.