Skip to content

Commit 24ff59d

Browse files
committed
support carbonimmutable
1 parent 4e3c45a commit 24ff59d

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

database/factories/InvoiceFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Elegantly\Invoices\Database\Factories;
66

7-
use Carbon\Carbon;
7+
use Carbon\CarbonImmutable;
88
use Elegantly\Invoices\Enums\InvoiceState;
99
use Elegantly\Invoices\Enums\InvoiceType;
1010
use Elegantly\Invoices\Models\Invoice;
@@ -23,7 +23,7 @@ class InvoiceFactory extends Factory
2323
public function definition()
2424
{
2525
$created_at = fake()->dateTime(
26-
max: Carbon::create(2024, 12, 31)
26+
max: CarbonImmutable::create(2024, 12, 31)
2727
);
2828

2929
return [

src/Models/Invoice.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Elegantly\Invoices\Models;
66

77
use Brick\Money\Money;
8-
use Carbon\Carbon;
8+
use Carbon\CarbonInterface;
99
use Elegantly\Invoices\Casts\Discounts;
1010
use Elegantly\Invoices\Contracts\HasLabel;
1111
use Elegantly\Invoices\Database\Factories\InvoiceFactory;
@@ -38,11 +38,11 @@
3838
* @property ?Invoice $credit
3939
* @property string $type
4040
* @property string $state
41-
* @property ?Carbon $state_set_at
41+
* @property ?CarbonInterface $state_set_at
4242
* @property string $description
4343
* @property ?array<string, mixed> $seller_information
4444
* @property ?array<string, mixed> $buyer_information
45-
* @property ?Carbon $due_at
45+
* @property ?CarbonInterface $due_at
4646
* @property ?string $tax_type
4747
* @property ?string $tax_exempt
4848
* @property Collection<int, InvoiceItem> $items
@@ -55,8 +55,8 @@
5555
* @property ?Model $invoiceable
5656
* @property ?int $invoiceable_id
5757
* @property ?string $invoiceable_type
58-
* @property Carbon $created_at
59-
* @property Carbon $updated_at
58+
* @property CarbonInterface $created_at
59+
* @property CarbonInterface $updated_at
6060
* @property InvoiceDiscount[] $discounts
6161
* @property ?array<array-key, mixed> $metadata
6262
* @property ?Money $subtotal_amount

src/Models/InvoiceItem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Elegantly\Invoices\Models;
66

77
use Brick\Money\Money;
8-
use Carbon\Carbon;
8+
use Carbon\CarbonInterface;
99
use Elegantly\Invoices\Database\Factories\InvoiceItemFactory;
1010
use Elegantly\Invoices\Pdf\PdfInvoiceItem;
1111
use Elegantly\Money\MoneyCast;
@@ -27,8 +27,8 @@
2727
* @property ?string $description
2828
* @property ?ArrayObject<array-key, mixed> $metadata
2929
* @property int $invoice_id
30-
* @property Carbon $created_at
31-
* @property Carbon $updated_at
30+
* @property CarbonInterface $created_at
31+
* @property CarbonInterface $updated_at
3232
*/
3333
class InvoiceItem extends Model
3434
{

src/Pdf/PdfInvoice.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Brick\Math\RoundingMode;
88
use Brick\Money\Money;
9-
use Carbon\Carbon;
9+
use Carbon\CarbonInterface;
1010
use Dompdf\Dompdf;
1111
use Elegantly\Invoices\Concerns\FormatForPdf;
1212
use Elegantly\Invoices\Contracts\HasLabel;
@@ -40,9 +40,9 @@ public function __construct(
4040
public HasLabel|string $type = InvoiceType::Invoice,
4141
public HasLabel|string $state = InvoiceState::Draft,
4242
public ?string $serial_number = null,
43-
public ?Carbon $created_at = null,
44-
public ?Carbon $due_at = null,
45-
public ?Carbon $paid_at = null,
43+
public ?CarbonInterface $created_at = null,
44+
public ?CarbonInterface $due_at = null,
45+
public ?CarbonInterface $paid_at = null,
4646
public array $fields = [],
4747

4848
public Seller $seller = new Seller,

tests/Feature/InvoiceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
declare(strict_types=1);
44

55
use Carbon\Carbon;
6+
use Carbon\CarbonInterface;
67
use Elegantly\Invoices\Enums\InvoiceType;
78
use Elegantly\Invoices\Models\Invoice;
89
use Elegantly\Invoices\Models\InvoiceItem;
910
use Illuminate\Database\Eloquent\Collection;
1011

1112
it('can set the right serial number year and month from a date', function (
1213
?string $format,
13-
?Carbon $date,
14+
?CarbonInterface $date,
1415
?int $expectedYear,
1516
?int $expectedMonth,
1617
) {

0 commit comments

Comments
 (0)