Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlbertLens's avatar

Laravel Nova export to PDF not working. Help please

Hello, I need to have an action in all resources to export to pdf the selected and/or filtered records of the resource. I am trying to use: https://novapackages.com/packages/padocia/laravel-nova-pdf

I have installed following directions and keep receiving an error: Too few arguments to function Laravel\Nova\Actions\Action::fields(), 0 passed in c:\laravel\nova\vendor\eparment\nova-dependency-container\src\Http\ActionRequest.php on line 21 abd exactly 1 expected.

It is not really an invoice (though I am keeping the name of the example). I need to export records shown and selected by the user.

My InvoiceAction.php inside Nova\Actions

class InvoiceAction extends ExportToPdf
{
    /**
     * @param  \Laravel\Nova\Fields\ActionFields  $fields
     * @param  \Illuminate\Support\Collection  $models
     *
     * @return \Illuminate\View\View
     */
    public function preview(ActionFields $fields, Collection $models) : View
    {
        $resource = $this->resource;
        return view('nova-pdf.template', compact($models,$resource));
    }

}

My actions part of code inside the Tienda.php resource inside Nova (Tienda is my first example of many)

    public function actions(NovaRequest $request)
    {
        return [
            new InvoiceAction,
        ];
    }

Any ideas or help, please?

Thank you

0 likes
1 reply
AlbertLens's avatar

Also with the standard original way:

    public function preview(ActionFields $fields, Collection $models) : View
    {
        $resource = $this->resource;
        return view('nova-pdf.template', compact('models','resource'));
    }

it fails and gives the same error.

And also, trying to pass fields as a new compact value:

    public function preview(ActionFields $fields, Collection $models) : View
    {
        $resource = $this->resource;
        return view('nova-pdf.template', compact('models','resource','fields'));
    }

it still gives the same error.

Please or to participate in this conversation.