Skip to content

BelongsToMany joins should fail if arguments not given like the docs #193

@christian-nielsen

Description

@christian-nielsen
return AccessAddress::query()
  ->joinRelationship("contracts", fn($join) => $join->where("column", "someting"))
  ->count();

Doing this with belongsTomany relationship (contracts) will not fail, but the were sentence (column, something) will never be applied.

The docs does say you should do something like:

User::joinRelationship('groups', [
    'groups' => [
        'groups' => function ($join) {
            // ...
        },
        // group_members is the intermediary table here
        'group_members' => fn ($join) => $join->where('group_members.active', true),
    ]
]);

It would make sense to throw an error to prevent implementing it wrong

or make it if you use a callback it would use it like this underneed:

AccessAddress::query()->joinRelationship('contracts', [
'contracts' => fn($join) => $join->where("column", "someting"))
])->count();

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions