refactor: update model casts to use method syntax across multiple models.
This commit is contained in:
parent
f6a1abfa0e
commit
4c444c703d
@ -16,15 +16,18 @@ class DelayedGood extends Model
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'stored_date' => 'date',
|
{
|
||||||
'payment_date' => 'date',
|
return [
|
||||||
'quantity' => 'integer',
|
'stored_date' => 'date',
|
||||||
'unit_price' => 'integer',
|
'payment_date' => 'date',
|
||||||
'total_amount' => 'integer',
|
'quantity' => 'integer',
|
||||||
'paid_amount' => 'integer',
|
'unit_price' => 'integer',
|
||||||
'is_paid' => 'boolean',
|
'total_amount' => 'integer',
|
||||||
];
|
'paid_amount' => 'integer',
|
||||||
|
'is_paid' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function customer(): BelongsTo
|
public function customer(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,9 +13,12 @@ class EggPrice extends Model
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'price' => 'integer',
|
{
|
||||||
];
|
return [
|
||||||
|
'price' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function unit(): BelongsTo
|
public function unit(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,7 +14,10 @@ class Expense extends Model implements HasMedia
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'expense_date' => 'date',
|
{
|
||||||
];
|
return [
|
||||||
|
'expense_date' => 'date',
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,10 +16,13 @@ class FeedPurchase extends Model
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'purchase_date' => 'date',
|
{
|
||||||
'total_price' => 'integer',
|
return [
|
||||||
];
|
'purchase_date' => 'date',
|
||||||
|
'total_price' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function items(): HasMany
|
public function items(): HasMany
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,11 +13,14 @@ class FeedPurchaseItem extends Model
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'quantity' => 'integer',
|
{
|
||||||
'unit_price' => 'integer',
|
return [
|
||||||
'subtotal' => 'integer',
|
'quantity' => 'integer',
|
||||||
];
|
'unit_price' => 'integer',
|
||||||
|
'subtotal' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected function formattedUnitPrice(): Attribute
|
protected function formattedUnitPrice(): Attribute
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,13 +13,16 @@ class Order extends Model
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
protected $casts = [
|
protected function casts(): array
|
||||||
'order_date' => 'date',
|
{
|
||||||
'egg_quantity' => 'integer',
|
return [
|
||||||
'unit_price' => 'integer',
|
'order_date' => 'date',
|
||||||
'total_amount' => 'integer',
|
'egg_quantity' => 'integer',
|
||||||
'discount' => 'integer',
|
'unit_price' => 'integer',
|
||||||
];
|
'total_amount' => 'integer',
|
||||||
|
'discount' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function customer(): BelongsTo
|
public function customer(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user