with or withCount with users relation shows an error. #1795
Replies: 15 comments 1 reply
-
Same issue here. Just a simple... Yields |
Beta Was this translation helpful? Give feedback.
-
In case it helps here is more information from the stacktrace... #2 /laravel/vendor/spatie/laravel-permission/src/Models/Role.php(68): Illuminate\Database\Eloquent\Model->morphedByMany() |
Beta Was this translation helpful? Give feedback.
-
@rsecor i did try Using
|
Beta Was this translation helpful? Give feedback.
-
@erikn69 Tried Thoughts? |
Beta Was this translation helpful? Give feedback.
-
@rsecor we have the same, also 'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
///
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
], custom changes on I can't replicate your error, but laravel-permission/src/Models/Role.php Lines 63 to 69 in 0e39dcc |
Beta Was this translation helpful? Give feedback.
-
PHP 7.4.16 |
Beta Was this translation helpful? Give feedback.
-
Tried |
Beta Was this translation helpful? Give feedback.
-
Curious... @erikn69 What authentication package are you using and how do you have it setup? |
Beta Was this translation helpful? Give feedback.
-
I did follow documentation indications
|
Beta Was this translation helpful? Give feedback.
-
Wondering if sanctum or some other package is causing an issue.
|
Beta Was this translation helpful? Give feedback.
-
@rsecor try this, go to vendor |
Beta Was this translation helpful? Give feedback.
-
@erikn69 Using the information you gave I found that... After som digging... Odd. |
Beta Was this translation helpful? Give feedback.
-
There is, you have to handle sanctum guard_name 'guards' => [
'sanctum' => [
'driver' => 'sanctum',
'provider' => 'users',
], It's an idea, I don't use sanctum, maybe it's wrong |
Beta Was this translation helpful? Give feedback.
-
Adding that blows everything up. |
Beta Was this translation helpful? Give feedback.
-
You have to add roles and permissions with guard_name 'sanctum' on db too, or use a wildcard '*' |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
with or withCount works with permissions relation but when you add users relation it shows an error.
And also when you do it on tinker it goes completely fine.
Very strange
My code
Error
Beta Was this translation helpful? Give feedback.
All reactions