Skip to content

Commit b3a2c0b

Browse files
committed
add default state
1 parent fcd405f commit b3a2c0b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Invoice.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @property string $description
3131
* @property ?ArrayObject $seller_information
3232
* @property ?ArrayObject $buyer_information
33-
* @property ?InvoiceState $state
33+
* @property InvoiceState $state
3434
* @property ?Carbon $state_set_at
3535
* @property ?Carbon $due_at
3636
* @property ?string $tax_type
@@ -61,6 +61,7 @@ class Invoice extends Model implements Attachable
6161

6262
protected $attributes = [
6363
'type' => InvoiceType::Invoice,
64+
'state' => InvoiceState::Draft,
6465
];
6566

6667
protected $guarded = [];
@@ -363,8 +364,8 @@ public function toPdfInvoice(): PdfInvoice
363364
{
364365
return new PdfInvoice(
365366
name: $this->type->trans(),
367+
state: $this->state->trans(),
366368
serial_number: $this->serial_number,
367-
state: $this->state?->trans(),
368369
paid_at: ($this->state === InvoiceState::Paid) ? $this->state_set_at : null,
369370
due_at: $this->due_at,
370371
created_at: $this->created_at,

src/PdfInvoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PdfInvoice
1919
*/
2020
public function __construct(
2121
public ?string $name = null,
22-
public string $state = InvoiceState::Draft->value,
22+
public ?string $state = null,
2323
public ?string $serial_number = null,
2424
public ?array $buyer = null,
2525
public ?Carbon $due_at = null,

0 commit comments

Comments
 (0)