- Make 1 - COMPANY a header with next company link
Write a custom paginator whereby you paginate employee information.
When that company is at end, have your next company link paginate to next company, like
https://drive.google.com/file/d/0B1_PFw--3o74YVliNHAxbzd4Z2c/view?usp=sharing
This was just a quick example, not formatted or prettied up as a quick demo of a double paginator.
Top header is owner, with paginated pets. Most in quick example had no pets, again quick example.
You could also write a triple paginator if needed. Of course if this stuff is just a short list, you may not even need any pagination.
In that case, just use the working query (if your example above works) and getPdo();
And / or see
http://dsmithweb.com/itemized.png
and
http://laravel.io/forum/04-04-2015-looping-through-collection
and
https://laracasts.com/discuss/channels/laravel/complex-query-for-a-report
and remember most complex reporting is NOT active record, but like a single page app. Just like I showed here.
You have to ALLOW and take no data and nulls into account. Checking for null in your results.
Another solution is having extra columns in the tables to "cut down" on the many to many problem. Sometimes it's better to have 3 one to many worked than a many to many mess. Read: http://laravel.io/forum/05-12-2015-has-many-through-relationship-depth