Closed matthewjumpsoffbuildings closed 3 years ago
@matthewjumpsoffbuildings there's not way to get the lens key via the resource or lens?
@patrickbrouwers as per my comment in #90 I think the only possible solution is to check the query for a group clause and if its a single column, use that?
Also can you clarify why my PR is failing the styleCI check? edit nvm, double spaced phpdoc params
@patrickbrouwers I will make another PR with the detection of group clause
Thanks, no need to worry about styleci details, it will be auto fixed on merge anyway.
As per issue #90 - when using an export query that is not
forAllMatchingResources
, the default behaviour was to use the LaravelwithKey
which selects the primary key (usuallyid
) of the Resource in question, disregarded the key of the Lens for that resource (which may be an aggregate lens usingCOUNT()
andGROUP BY
SQL)The solution as best as I can see, is to allow overriding this behaviour using a
withExportQueryKey()
option that lets the user specify a different key for a Lens Action. If there is a cleaner or more 'Laravel' way to do it, that would be great, but this does fix the issue and let me use paginated downloadable Excel Actions from aggregate Lenses.