SpartnerNL / Laravel-Nova-Excel

🚀 Supercharged Excel exports for Laravel Nova Resources
https://docs.laravel-excel.com/nova/1.0/
MIT License
378 stars 73 forks source link

Use Group clause in ExportLensActionRequest to allow for aggregate Lens exports #127

Closed matthewjumpsoffbuildings closed 3 years ago

matthewjumpsoffbuildings commented 3 years ago

As per issue #90 - when using an export query that is not forAllMatchingResources, the default behaviour was to use the Laravel withKey which selects the primary key (usually id) of the Resource in question, disregarded the key of the Lens for that resource (which may be an aggregate lens using COUNT() and GROUP BY SQL)

The solution is to check for a groups clause in the Lenses underlying query builder, and if it exists, to use that with a whereIn() instead

patrickbrouwers commented 3 years ago

Thanks @matthewjumpsoffbuildings