<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Storage;

class UserAttachmentResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'              => $this->id,
            'type'            => $this->type,
            'document_number' => $this->document_number,
            'full_name'       => $this->full_name,
            'dob'             => $this->dob?->toDateString(),
            'expiry_date'     => $this->expiry_date?->toDateString(),
            'nationality'     => $this->nationality,
            'issuing_country' => $this->issuing_country,
            'file_type'       => $this->file_type,
            'file_url'        => Storage::url($this->file_path),
            'is_verified'     => $this->is_verified,
            'created_at'      => $this->created_at->toISOString(),
        ];
    }
}
