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

Laravel will load related records automatically when you try to access them, after running your query. You can also (and probably should) use Eager Loading so that it loads those related records straight away, saving on the number of queries being run...

http://laravel.com/docs/eloquent#eager-loading

$locations = Locations::with('relationship')->where('location_id', '=', $location_id)->get();

// Blade
@foreach($locations as $location)
  @foreach($location->relationship as $relationship)
    // Access relationships here...
  @endforeach
@endforeach
Last updated 1 year ago.
0

Thanks, I think I can make this work.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.