<?php

namespace App\Http\Resources\Api\V1\Vendor\Order;

use App\Models\Ecommerce\Product\Order\Status\OrderStatus;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class VendorOrderIndexResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'status' => OrderStatus::formattedStatusFor($this->status),
            'shipping_method' => $this->formattedShippingMethod(),
            'notes' => $this->notes,
            'delivery_time' => $this->delivery_time,
            'delivery_at' => $this->delivery_at?->format('d.m.Y'),
            'region' => $this->region,
            'payment_type' => $this->paymentType?->name,
        ];
    }
}
