<?php

namespace App\Http\Resources\Results;

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

class ResultResourceCollection extends ResourceCollection
{
    private Array | null $counters;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct($data, Array $counters = null)
    {
        parent::__construct($data);
        $this->counters = $counters;
    }

    /**
     * Transform the resource collection into an array.
     *
     * @return array<int|string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'data' => ResultResource::collection($this->collection),
            'counters' => $this->counters,
        ];
    }
}
