Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dom's avatar
Level 7

Help with a relationship spanning multiple tables

Hey guys,

I'm starting to get back into Laravel and some concepts are kind of hard to grasp. I have a problem with a specific relationship I hope to get help with solving.

I have 3 tables:

  • shops
  • review_sites
  • review_urls

Inside of shops there are various shop related columns but no direct relationships with the other 2 tables.

Inside of review_sites there is just an id and a name column.

Inside of review_urls there is the id, site_id, shop_id, and url columns.

What I'd like to be able to do is grab the data so it returns the shop, a list of the review sites and within that list the review url for each one. For example:

Shop (array) -> Review Site (array) -> IF there's an entry in review_urls for this site then Review URL

I hope this makes sense. If I can make anything clearer please let me know!

P.S. if you know of a video where Jeffrey goes over this please link it so I can watch.

0 likes
3 replies
Dom's avatar
Level 7

I figured it out. It turns out I had the relationships set up correctly, but the fact my controllers were named like Review_URL instead of Review_Url screwed it up somehow. Changed that and I'm all set. Thank you for the replies!

Please or to participate in this conversation.