laratrust icon indicating copy to clipboard operation
laratrust copied to clipboard

Custom team column

Open micobarac opened this issue 3 years ago • 1 comments

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?

micobarac avatar Feb 14 '21 14:02 micobarac

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).

GregPeden avatar Apr 30 '21 21:04 GregPeden

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.

filippotoso avatar Feb 20 '23 14:02 filippotoso