diff --git a/app/Services/PdfMaker/Designs/Bold.php b/app/Services/PdfMaker/Designs/Bold.php index 5d401ccfbd..5abe49dae4 100644 --- a/app/Services/PdfMaker/Designs/Bold.php +++ b/app/Services/PdfMaker/Designs/Bold.php @@ -32,21 +32,26 @@ class Bold extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() { return file_get_contents( - base_path('resources/views/pdf-designs//bold.html') + base_path('resources/views/pdf-designs/bold.html') ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Business.php b/app/Services/PdfMaker/Designs/Business.php index 2ad7ef3298..a5adbc706c 100644 --- a/app/Services/PdfMaker/Designs/Business.php +++ b/app/Services/PdfMaker/Designs/Business.php @@ -32,21 +32,26 @@ class Business extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() { return file_get_contents( - base_path('resources/views/pdf-designs//business.html') + base_path('resources/views/pdf-designs/business.html') ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Clean.php b/app/Services/PdfMaker/Designs/Clean.php index 3b79c971d8..5949d432da 100644 --- a/app/Services/PdfMaker/Designs/Clean.php +++ b/app/Services/PdfMaker/Designs/Clean.php @@ -32,7 +32,7 @@ class Clean extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() @@ -42,11 +42,16 @@ class Clean extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Creative.php b/app/Services/PdfMaker/Designs/Creative.php index 8fae8e662c..8b78e36527 100644 --- a/app/Services/PdfMaker/Designs/Creative.php +++ b/app/Services/PdfMaker/Designs/Creative.php @@ -32,21 +32,26 @@ class Creative extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() { return file_get_contents( - base_path('resources/views/pdf-designs//creative.html') + base_path('resources/views/pdf-designs/creative.html') ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Elegant.php b/app/Services/PdfMaker/Designs/Elegant.php index 46b1ddcc7f..752d7f1cdc 100644 --- a/app/Services/PdfMaker/Designs/Elegant.php +++ b/app/Services/PdfMaker/Designs/Elegant.php @@ -32,7 +32,7 @@ class Elegant extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() @@ -42,11 +42,16 @@ class Elegant extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Hipster.php b/app/Services/PdfMaker/Designs/Hipster.php index a1032ded3e..4f08da9de8 100644 --- a/app/Services/PdfMaker/Designs/Hipster.php +++ b/app/Services/PdfMaker/Designs/Hipster.php @@ -32,7 +32,7 @@ class Hipster extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() @@ -42,11 +42,16 @@ class Hipster extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Modern.php b/app/Services/PdfMaker/Designs/Modern.php index f091ed0062..a6297e4605 100644 --- a/app/Services/PdfMaker/Designs/Modern.php +++ b/app/Services/PdfMaker/Designs/Modern.php @@ -32,7 +32,7 @@ class Modern extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() @@ -42,11 +42,16 @@ class Modern extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Plain.php b/app/Services/PdfMaker/Designs/Plain.php index ff0d90658c..cd7de4f96a 100644 --- a/app/Services/PdfMaker/Designs/Plain.php +++ b/app/Services/PdfMaker/Designs/Plain.php @@ -32,7 +32,7 @@ class Plain extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html(): ?string @@ -42,11 +42,16 @@ class Plain extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/app/Services/PdfMaker/Designs/Playful.php b/app/Services/PdfMaker/Designs/Playful.php index 35bc1cf729..a3c512b3d8 100644 --- a/app/Services/PdfMaker/Designs/Playful.php +++ b/app/Services/PdfMaker/Designs/Playful.php @@ -32,7 +32,7 @@ class Playful extends BaseDesign /** Global state of the design, @var array */ public $context; - /** Type of entity => invoice||quote */ + /** Type of entity => product||task */ public $type; public function html() @@ -42,11 +42,16 @@ class Playful extends BaseDesign ); } - public function elements(array $context, string $type = 'invoice'): array + public function elements(array $context, string $type = 'product'): array { $this->context = $context; + $this->type = $type; + if ($type !== 'product' || $type !== 'task') { + throw new \Exception("Type '{$type}' is not allowed. Allowed values are 'product' or 'task'."); + } + $this->setup(); return [ diff --git a/tests/Feature/PdfMaker/ExampleIntegrationTest.php b/tests/Feature/PdfMaker/ExampleIntegrationTest.php index 72f3ee9f0d..f2f032d480 100644 --- a/tests/Feature/PdfMaker/ExampleIntegrationTest.php +++ b/tests/Feature/PdfMaker/ExampleIntegrationTest.php @@ -35,7 +35,7 @@ class ExampleIntegrationTest extends TestCase 'variables' => $engine->generateLabelsAndValues(), ]; - $maker = new PdfMaker($state, 'invoice'); + $maker = new PdfMaker($state, 'product'); $maker ->design(Plain::class)