<?php

declare(strict_types=1);

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Mtc\MercuryDataModels\VehicleCheckFailure;

class VehicleCheckFailureListResource extends JsonResource
{
    public static $wrap = '';

    public function toArray($request)
    {
        $this->resource->through(fn (VehicleCheckFailure $record) => [
            'id' => $record->id,
            'type' => $record->type,
            'driver' => $record->driver,
            'registration' => $record->registration,
            'mileage' => $record->mileage,
            'error' => $record->error,
            'hits' => $record->hits,
            'created_at' => $record->created_at,
            'updated_at' => $record->updated_at,
        ]);

        return $this->resource->toArray();
    }
}
