<?php

declare(strict_types=1);

namespace App\Http\Controllers;

use App\Http\Resources\VehicleCheckFailureListResource;
use Illuminate\Http\Request;
use Mtc\MercuryDataModels\VehicleCheckFailure;

class VehicleCheckFailureController extends Controller
{
    public function index(Request $request): VehicleCheckFailureListResource
    {
        $perPage = min((int) $request->input('per_page', 15), 200);

        $entries = VehicleCheckFailure::query()
            ->orderByDesc('updated_at')
            ->paginate($perPage);

        return new VehicleCheckFailureListResource($entries);
    }
}
