Level 88
Your query looks correct. Do you also add get or first to the query? Right now you don't actually perform the query. Because of that, the data is also not auto-loaded.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This is my query
$car = Car::query()
->orderby('id', 'desc') )
->with('User')
I expect Laravel would eager load the user object here? When I call $car->User->age I get multiple queries.
What is going wrong here?
Your query looks correct. Do you also add get or first to the query? Right now you don't actually perform the query. Because of that, the data is also not auto-loaded.
Please or to participate in this conversation.