Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize Export Fields Based On User Input #74

Open
MannikJ opened this issue Dec 10, 2019 · 1 comment
Open

Customize Export Fields Based On User Input #74

MannikJ opened this issue Dec 10, 2019 · 1 comment

Comments

@MannikJ
Copy link

MannikJ commented Dec 10, 2019

As far as I see it is quite hard to hook in user input to decide which fields to export, because of how the design of the DownloadExcel action.

I know I can overwrite various functions etc. but I have no access to the values of the fields at that time.

So how am I supposed to implement that the user can choose the input fields dynamically?

@anditsung
Copy link

this is the solution that im using

create a class and extends to DownloadExcel

on handle function

/**
     * @param ActionRequest $request
     * @param Action        $exportable
     *
     * @return array
     */
    public function handle(ActionRequest $request, Action $exportable): array
    {
        $exportable->query = $this->customQuery($request);
        ....
    }

    private function customQuery($request)
    {
        return Model::all();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants