Support the ongoing development of →
Eloquent Database API
Last updated by @kalyklos 2 years ago.

If your pivot has a primary key (id) you can make a model for the pivot table and have a relation from your product to that model. Alternatively you can add a join in your eager load query. Another option would be to extract your city_id, make a query in your cities table using DB query builder (since it's faster then eloquent), after that go in your relation and use the '->setAttribute(key, value)' method to add the city name obtained in the separate query


Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.