Back

eager loading question / issue ?


rawrkats posted 4 months ago

I've got this :

        $location = \App\Location::find($location_id)->with('items','items.vendors')->get();

but its not using the find($location_id) and its returning all locations collections in the database. if I drop everything starting at ->with, it returns just a single location collection.

Am I doing something wrong with the syntax?

jay4yam replied 4 months ago Solution

Try :

$location = \App\Location::with('items', 'items.vendor')->findOrFail($location_id);

Sign in to participate in this thread!



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