Query model without loading permissions #2212
Unanswered
theisnygaard
asked this question in
Q&A
Replies: 1 comment
-
Hi, that is weird Showing a list of all users do not bring any roles/permissions, it must be something on your implementation, try to replicate the problem on a fresh instalation and share it here |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
We have implemented the permission system in our Laravel which is working perfectly fine, but we're slowly seeing performance issues when handling large collections.
We have a
User
model which uses theHasRoles
andHasPermissions
traits. In one of our views, we're showing a list of all users which has become quite slow. When inspecting the queries made to the database, the model seems to automatically load all permissions and roles related to that specific model (N+1), which is unnecessary at this point, since we're merely displaying meta data columns.Is it possible to query the model without loading the permissions? We've tried disabling the
roles
andpermissions
relationships via thewithout
method, but with no luck.Versions: Laravel
^8.0
and Spatie Laravel Permissions^5.5
.Thanks is advance.
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions