'integer', 'discount' => 'integer', 'total' => 'integer', ]; } public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by_id'); } public function items(): HasMany { return $this->hasMany(PurchaseItem::class); } public function supplier(): BelongsTo { return $this->belongsTo(Supplier::class); } public function createdAtFormatted(): Attribute { return Attribute::make( get: fn () => $this->created_at?->translatedFormat('l, d F Y H:i'), ); } public function discountFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->discount, 0, ',', '.'), ); } public function subtotalFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->subtotal, 0, ',', '.'), ); } public function totalFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->total, 0, ',', '.'), ); } public static function mediaModuleName(): string { return 'purchase'; } public function registerMediaCollections(): void { $this->addMediaCollection('photos'); } }