'New', self::FULFILLMENT_CONFIRMED => 'Confirmed', self::FULFILLMENT_PREPARING => 'Preparing', self::FULFILLMENT_READY => 'Ready', self::FULFILLMENT_DELIVERED => 'Delivered', self::FULFILLMENT_CANCELLED => 'Cancelled', ]; protected $fillable = [ 'woo_store_id', 'external_order_id', 'order_number', 'wc_status', 'payment_status', 'customer_name', 'customer_email', 'customer_phone', 'line_items', 'billing_address', 'shipping_address', 'currency', 'total_minor', 'fulfillment_status', 'wc_updated_at', 'metadata', ]; protected $casts = [ 'line_items' => 'array', 'billing_address' => 'array', 'shipping_address' => 'array', 'metadata' => 'array', 'total_minor' => 'integer', 'wc_updated_at' => 'datetime', ]; public function store(): BelongsTo { return $this->belongsTo(WooStore::class, 'woo_store_id'); } public function fulfillmentLabel(): string { return self::FULFILLMENT_STATUSES[$this->fulfillment_status ?? self::FULFILLMENT_NEW] ?? ucfirst((string) $this->fulfillment_status); } public function totalFormatted(): string { $minor = (int) $this->total_minor; $currency = strtoupper(trim((string) ($this->currency ?: ''))); if ($currency === '' && ($this->relationLoaded('store') || $this->store)) { $currency = $this->store->currency(); } $amount = number_format($minor / 100, 2); return $currency !== '' ? $currency.' '.$amount : $amount; } }