From 1251eac02708bfb247b1c996574ebab140cbf9f0 Mon Sep 17 00:00:00 2001 From: freekmurze Date: Wed, 27 Dec 2023 11:35:51 +0000 Subject: [PATCH] Fix styling --- src/Pdf.php | 12 +++++++++--- tests/PdfReponseTest.php | 3 ++- tests/PdfTest.php | 4 ++-- tests/Pest.php | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Pdf.php b/src/Pdf.php index 3ae144f..f051286 100755 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -12,15 +12,21 @@ class Pdf implements Responsable { public string $viewName = ''; + public array $data = []; + public string $html = ''; public string $headerViewName = ''; + public array $headerData = []; + public ?string $headerHtml = null; public string $footerViewName = ''; + public array $footerData = []; + public ?string $footerHtml = null; public string $downloadName = ''; @@ -90,7 +96,7 @@ public function inline(string $downloadName = ''): self $this->name($downloadName); $this->addHeaders([ - 'Content-Type' => 'application/pdf', + 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; filename="'.$this->downloadName.'"', ]); @@ -118,12 +124,12 @@ public function footerHtml(string $html): self return $this; } - public function download(string $downloadName = null): self + public function download(?string $downloadName = null): self { $this->name($downloadName); $this->addHeaders([ - 'Content-Type' => 'application/pdf', + 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="'.$this->downloadName.'"', ]); diff --git a/tests/PdfReponseTest.php b/tests/PdfReponseTest.php index 905fe93..cbf98ef 100644 --- a/tests/PdfReponseTest.php +++ b/tests/PdfReponseTest.php @@ -1,6 +1,7 @@ assertHeader('content-disposition', 'attachment; filename="my-custom-name.pdf"'); }); -it('will inline the pdf by default', function() { +it('will inline the pdf by default', function () { Route::get('pdf', function () { return pdf('test')->name('my-custom-name.pdf'); }); diff --git a/tests/PdfTest.php b/tests/PdfTest.php index 61a3211..332e78b 100644 --- a/tests/PdfTest.php +++ b/tests/PdfTest.php @@ -51,7 +51,7 @@ ]); }); -it('can render header html', function() { +it('can render header html', function () { Pdf::html('Body html') ->headerView('header', ['title' => 'Header title']) ->save($this->targetPath); @@ -62,7 +62,7 @@ ]); }); -it('can render footer html', function() { +it('can render footer html', function () { Pdf::html('Body html') ->footerView('footer', ['title' => 'Footer title']) ->save($this->targetPath); diff --git a/tests/Pest.php b/tests/Pest.php index 41c8c51..6d595e1 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -65,7 +65,7 @@ function assertMatchesPdfSnapshot(string $pdfPath): void $expectedText = [$expectedText]; } - foreach($expectedText as $singleText) { + foreach ($expectedText as $singleText) { expect(str_contains($actualText, $singleText))->toBeTrue( "Expected text `{$singleText}` not found in `{$actualText}`"