-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use ->withPivot() for teamed relationships #2679
Conversation
Breaking tests so I’ll close but I am wondering if this is something to look in to? |
that's because you did it wrong, must be: if (! app(PermissionRegistrar::class)->teams) {
return $relation;
}
$teamsKey = app(PermissionRegistrar::class)->teamsKey;
$relation->withPivot($teamsKey);
$teamField = config('permission.table_names.roles').'.'.$teamsKey;
return $relation->wherePivot($teamsKey, getPermissionsTeamId())
->where(fn ($q) => $q->whereNull($teamField)->orWhere($teamField, getPermissionsTeamId())); Also, there is more places, not only there laravel-permission/src/Traits/HasPermissions.php Lines 88 to 92 in c99dca7
|
Oh yeah of course, I should have checked if teams is activated first before trying to access the config values. Corrected this now. |
Also added this for permissions |
@erikn69 good to merge? |
I am not a maintainer, |
@freekmurze @drbyte is this ok to merge? |
@drbyte thanks |
The previous implementation is giving me issues when querying ->getPivotColumns() for example. It should probably use ->withPivot() to indicate there is a pivot value.