Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 2 years ago.
0

Have you installed the debug bar? Let you see what queries you are running and what the bottleneck is?

https://github.com/barryvdh/laravel-debugbar

Must have package for laravel.

0

Try this

$phones = Phone::where(function($query){
...
} //end of closure
)->whereHas('productnum')
->paginate(10);
0

Thank you for your answers. jacksoncharles i ll try it asap..

Firtzberg it gives me the following error when i try

		})->whereHas('productnum')->paginate(10);

Argument 2 passed to Illuminate\Database\Eloquent\Builder::whereHas() must be an instance of Closure, none given, called in /home/xxx/app/controllers/PhoneController.php on line 90 and defined
Last updated 9 years ago.
0

My mistake. It should be ->has() instead of ->whereHas() in my code

0

thank you Firtzberg!! It works fine now :)

0

I'm glad I was helpful.
You didn't use whereHas correctly. In your aproach the database had to check the conditions inside the query for each product separate, i.e. thousands of times for each phone, while in my code the conditions were checked only once for each phone.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

George george Joined 10 Mar 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.