'date', ]; protected $appends = [ 'total', ]; public function getTotalAttribute(): float { $embDigitizingTotal = $this->embroideryEntries()->sum('digitizing_cost'); $embRunChargeTotal = $this->embroideryEntries()->sum('run_charge'); $scpTotal = $this->screenPrintEntries->sum(fn (ScreenPrintEntry $record) => $record->total_price); $heatTransferTotal = $this->heatTransferEntries()->sum('price'); return $embDigitizingTotal + $embRunChargeTotal + $scpTotal + $heatTransferTotal; } public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } public function embroideryEntries(): HasMany { return $this->hasMany(EmbroideryEntry::class); } public function screenPrintEntries(): HasMany { return $this->hasMany(ScreenPrintEntry::class); } public function heatTransferEntries(): HasMany { return $this->hasMany(HeatTransferEntry::class); } }