There is a car dealers listing with pagination where I need to show first 3 cars with that car's manufacturer and model no of that dealer. Its like
Car Dealer 1
- car 1 -> Fetching car's Manufacturer from manufacturer table and model from model table
- car 2 -> Fetching car's Manufacturer from manufacturer table and model from model table
- car 3 -> Fetching car's Manufacturer from manufacturer table and model from model table
Car Dealer 2
- car 1 -> Fetching car's Manufacturer from manufacturer table and model from model table
- car 2 -> Fetching car's Manufacturer from manufacturer table and model from model table
- car 3 -> Fetching car's Manufacturer from manufacturer table and model from model table
and so on with pagination
Its obvious that querying in loop is not a good solution. Is there any good work around this problem?
I have checked hasManyThrough but it does not suits here.
its kind a query : get first 3 cars with manufacturer and model nos for each dealers in resultset. If Laravel relationship does not work then what queries should be used to avoid looping? Thanks