Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent

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?

Last updated 3 years ago.
0

Try :

$location = \App\Location::with('items', 'items.vendor')->findOrFail($location_id);
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

rawrkats rawrkats Joined 17 Aug 2014

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.

© 2025 Laravel.io - All rights reserved.