Support the ongoing development of Laravel.io →
Database Eloquent

categories

id, name

products

id, name

products_categories

id, product_id, category_id

cards

id, product_category_id, user, pass

as you can see i have four tables, products has many-to-many relationship with categories and cards has many-to-one relation with products_categories it means cards could belongs to many products_categories

i want to eager loading all categories with their products and also their product's cards, for this to happen should i create model class for products_categories table and what be it's relationships? or use sql query?

what you suggest..

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

samsoft samsoft Joined 15 Apr 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.