octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.

Home Page:https://octobercms.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Group Scope for Parent/Nested Relations

sqwk opened this issue · comments

commented

I have three models; client, project and task. Task belongs to project, project belongs to client. (Task has a db column project_id and project has a db column client_id.)

I can create a group filter scope for task belonging to project. Is it possible to also create a group filter scope for a more distant relation? (Effectively a belongsToThroughrelation, which is not implemented in Laravel.) Showing a column value in a list can be realised through an accessor, implementing a scope unfortunately does not work this way.

In case this is a feature request, this would be a syntax suggestion:

client:
    type: group
    nameFrom: name
    modelClass: [Namespace\Plugin\Models\Project, Namespace\Plugin\Models\Client]
commented

Hey @sqwk

I think the best approach here is to use optionsMethod to specify a model method and then return the results from this.