Skip to content

How to handle N+1 problem? #2951

Discussion options

You must be logged in to vote

I think the problem with eager loading is that you use $user->roles()->pluck('name') which makes a new request. Try using $user->roles->first()->name when using User::with('roles')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edpmasterindo
Comment options

Answer selected by edpmasterindo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants