shameless bump :)
Making Dynamic Eloquent Scopes
Evening all,
I have a certain problem that I need to solve, and I'm unsure of the best way to approach it.
Here's an example: I have a model: School. A School has many Students, and each student has many Guardians
The many-to-many relationship between Students and Guardians has some other properties, such as is_legal_guardian (boolean) and order (integer).
All of this is fine, however, I need each School to be able to set up what I can only describe as a filter, or a preset, so, that when retrieving the Guardians for each Student, the results are filtered by whatever the school has defined for a particular filter.
An example of this might be a school sets up a filter called "Legal Guardians who are first point of contact", where they only wish to return Guardians of each Student where the legal_guardian is true and the order equals 1.
The only way I can think of doing this is having a GuardianFilter model, and having Guardians linked to that, but unsure of how that relationship would work, when the relationship itself is defined by the School.
I apologise if this is difficult to follow, but am happy to provide further clarification if required.
Please or to participate in this conversation.