Skip to content

Commit 22defdb

Browse files
committed
Adopt the new casts method
1 parent 4b40736 commit 22defdb

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/Customers/CustomerModel.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ class CustomerModel extends Model
1616

1717
protected $guarded = [];
1818

19-
protected $casts = [
20-
'data' => 'json',
21-
];
19+
public function casts(): array
20+
{
21+
return [
22+
'data' => 'json',
23+
];
24+
}
2225

2326
public function orders(): HasMany
2427
{

src/Orders/OrderModel.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ class OrderModel extends Model
1818

1919
protected $guarded = [];
2020

21-
protected $casts = [
22-
'order_number' => 'integer',
23-
'items' => 'json',
24-
'grand_total' => 'integer',
25-
'items_total' => 'integer',
26-
'tax_total' => 'integer',
27-
'shipping_total' => 'integer',
28-
'coupon_total' => 'integer',
29-
'use_shipping_address_for_billing' => 'boolean',
30-
'gateway' => 'json',
31-
'data' => 'json',
32-
];
21+
public function casts(): array
22+
{
23+
return [
24+
'order_number' => 'integer',
25+
'items' => 'json',
26+
'grand_total' => 'integer',
27+
'items_total' => 'integer',
28+
'tax_total' => 'integer',
29+
'shipping_total' => 'integer',
30+
'coupon_total' => 'integer',
31+
'use_shipping_address_for_billing' => 'boolean',
32+
'gateway' => 'json',
33+
'data' => 'json',
34+
];
35+
}
3336

3437
public function customer(): BelongsTo
3538
{

src/Orders/StatusLogModel.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ class StatusLogModel extends Model
1616

1717
protected $guarded = [];
1818

19-
protected $casts = [
20-
'order_id' => 'integer',
21-
'timestamp' => 'datetime',
22-
'data' => 'json',
23-
];
19+
public function casts(): array
20+
{
21+
return [
22+
'order_id' => 'integer',
23+
'timestamp' => 'datetime',
24+
'data' => 'json',
25+
];
26+
}
2427

2528
public function order(): BelongsTo
2629
{

0 commit comments

Comments
 (0)