What are the duplicated queries?
Debugbar Shows over 300 queries
I just installed Laravel Debugbar and it's showing 320 queries on my page, many of them duplicates and from other methods.
it's almost as if I'm seeing every single query in my app all at once.
I'm accessing my index() method, which is very simple and uses eager loading, so I'm at a loss as to what's happening or even where to begin looking for answers.
My index method. Surely this isn't producing 320 queries...
public function index()
{
$user = User::where('id', auth()->user()->id)
->with('following')
->with('categories')
->first();
$mycats = $user->categories->pluck('category_id')->toArray();
return view('explore.index', compact('mycats'));
}
Here's the message from debugbar: 320 statements were executed, 315 of which were duplicated, 5 unique
Any suggestions?
do you have view composers?
btw as you are not actually passing the user to the view, just eager loading relations, you could do this with just
auth()->user()->load('following','categories');
Please or to participate in this conversation.