'decimal:2', 'unit_price' => 'decimal:2', 'total' => 'decimal:2', ]; } public function invoice(): BelongsTo { return $this->belongsTo(FinancialInvoice::class, 'invoice_id'); } protected static function booted(): void { static::saving(function (self $item) { $item->total = (float) $item->quantity * (float) $item->unit_price; }); } }