Support the ongoing development of Laravel.io →
Eloquent Database API
Last updated by @kalyklos 7 months ago.
0

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

0

Sign in to participate in this thread!

LaraJobs

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.

© 2022 Laravel.io - All rights reserved.