<?php

namespace App\Http\Resources\Order;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class OrderReportResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->uuid,
            'product_images' => $this->whenLoaded('items')
                            ->pluck('product_image_url_snapshot')
                            ->values(),
            'total_items' => $this->total_items,
            'order_number' => $this->order_number,
            'total_amount' => $this->total_amount,
            'order_status' => $this->order_status,
            'delivery_type' => $this->delivery_type,
            'has_been_assessed' => $this->has_been_assessed,
            'created_at' => $this->created_at->toDateTimeString()
        ];
    }
}
