Support the ongoing development of Laravel.io →
Database Eloquent

Hello all, I have some model called location, which describe a location, (say the eiffel tower). This location has an album_id which corresponds to an album of photos. This album of photos has many photos throught a album_photos pivot table.

How can you go about it if you want to do something like

$location = Location::with('photos')->first();

I'm using https://github.com/Terumi/photogallery for the album

Thank you

Last updated 3 years ago.
0

Shouldn't you define the relation other way around, that Location has Album?

Nevertheless you can get photos with ease, but first elaborate how you want to use them so we can suggest the best way to go.

Last updated 3 years ago.
0

anyone plz?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Terumi terumi Joined 13 Feb 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.