spatie / laravel-pdf

Create PDF files in Laravel apps

Home Page:https://spatie.be/docs/laravel-pdf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: optional parameter in `download()` method is required

vintagesucks opened this issue · comments

What happened?

The docs suggest combining name() with download() like this:

return pdf()
->view('pdf.invoice', compact('invoice'))
->name('invoice-2023-04-10.pdf')
->download();

download does not require $downloadName to be set, but passes $downloadName to name(), which does:

public function download(?string $downloadName = null): self
{
$this->name($downloadName);

public function name(string $downloadName): self

This results in the following error when calling download() without $downloadName:

Spatie\LaravelPdf\PdfBuilder::name(): Argument #1 ($downloadName) must be of type string, null given

How to reproduce the bug

Use download() without an argument, as allowed by the method signature.

Package Version

1.3.0

PHP Version

8.2.16

Laravel Version

10.45.0

Which operating systems does with happen with?

macOS

Notes

No response

Same issue today, but thanks to your issue solved :D

This has been fixed in the latest release.