Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
christian-nielsen opened this issue Dec 11, 2024 · 0 comments

Comments

@christian-nielsen
Copy link

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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant