<?php

namespace App\Http\Resources\Api;

use App\Enums\QrCodeStatusEnum;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class QrCodeResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'           => $this->id,
            'code'         => $this->code,
            'status'       => $this->status,
            'name'         => $this->name ?? '-',
            'phone'        => $this->phone ?? '-',
            'car_number'   => $this->car_number ?? '-',
            'status_label' => QrCodeStatusEnum::label($this->status),
            'used_at'      => $this->used_at,
            'created_at'   => $this->created_at,
            'expires_at'   => $this->expires_at,
        ];
    }
}
