File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ class Invoice
3131 */
3232 public $ name ;
3333
34+ /**
35+ * Invoice template.
36+ *
37+ * @var string
38+ */
39+ public $ template ;
40+
3441 /**
3542 * Invoice item collection.
3643 *
@@ -139,6 +146,7 @@ class Invoice
139146 public function __construct ($ name = 'Invoice ' )
140147 {
141148 $ this ->name = $ name ;
149+ $ this ->template = 'default ' ;
142150 $ this ->items = Collection::make ([]);
143151 $ this ->currency = config ('invoices.currency ' );
144152 $ this ->tax = config ('invoices.tax ' );
@@ -166,6 +174,22 @@ public static function make($name = 'Invoice')
166174 return new self ($ name );
167175 }
168176
177+ /**
178+ * Select template for invoice.
179+ *
180+ * @method template
181+ *
182+ * @param string $template
183+ *
184+ * @return self
185+ */
186+ public function template ($ template = 'default ' )
187+ {
188+ $ this ->template = $ template ;
189+
190+ return $ this ;
191+ }
192+
169193 /**
170194 * Adds an item to the invoice.
171195 *
@@ -307,7 +331,7 @@ public function taxPriceFormatted()
307331 */
308332 private function generate ()
309333 {
310- $ this ->pdf = PDF ::generate ($ this );
334+ $ this ->pdf = PDF ::generate ($ this , $ this -> template );
311335
312336 return $ this ;
313337 }
Original file line number Diff line number Diff line change @@ -217,6 +217,17 @@ Invoice name.
217217
218218
219219
220+ * Visibility: ** public**
221+
222+
223+ ### $template
224+
225+ public string $template
226+
227+ Invoice template.
228+
229+
230+
220231* Visibility: ** public**
221232
222233
@@ -410,6 +421,18 @@ Return a new instance of Invoice.
410421* $name ** string**
411422
412423
424+ ### template
425+
426+ \ConsoleTVs\Invoices\Classes\Invoice ConsoleTVs\Invoices\Classes\Invoice::template(string $template)
427+
428+ Select template for invoice.
429+
430+ * Visibility: ** public**
431+ * Default: ** default**
432+
433+
434+ #### Arguments
435+ * $name ** template**
413436
414437### addItem
415438
@@ -713,5 +736,3 @@ Set the invoice footnote.
713736
714737#### Arguments
715738* $footnote ** string**
716-
717-
You can’t perform that action at this time.
0 commit comments