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!
We'd like to thank these amazing companies for supporting us
The Laravel portal for problem solving, knowledge sharing and community building.