OrderChannel::class, 'price_type' => PriceType::class, 'payment_type' => PaymentType::class, 'is_affiliate' => 'boolean', 'status' => OrderStatus::class, 'subtotal' => 'integer', 'discount' => 'integer', 'shipping_cost' => 'integer', 'marketplace_settings_snapshot' => 'array', 'total_amount' => 'integer', ]; } public function cashTransaction(): BelongsTo { return $this->belongsTo(CashTransaction::class); } public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by_id'); } public function marketing(): BelongsTo { return $this->belongsTo(User::class, 'marketing_id'); } public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } public function items(): HasMany { return $this->hasMany(OrderItem::class); } public function channelLabel(): Attribute { return Attribute::make( get: fn () => $this->channel->label(), ); } 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 shippingCostFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->shipping_cost, 0, ',', '.'), ); } public function totalAmountFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->total_amount, 0, ',', '.'), ); } public function paymentTypeLabel(): Attribute { return Attribute::make( get: fn () => $this->payment_type->label(), ); } public function priceTypeLabel(): Attribute { return Attribute::make( get: fn () => $this->price_type->label(), ); } public function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status->label(), ); } public function subtotalFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->subtotal, 0, ',', '.'), ); } }