<?php

namespace Modules\School\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\Response\ResponseService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

use Modules\School\Resources\Api\SchoolResource;
use Modules\School\Services\SchoolService;
class SchoolController extends Controller
{

    public function __construct(
        private SchoolService $schoolService,
    ) {
    }

    /**
     * Get Schools.
     *
     * @param Request $request
     * @return void
     */
    public function index(Request $request): void
    {
        $credentials = $request->only('title');
        $credentials['api'] = true;
        $query = $this->schoolService->get($credentials);

        $response = ["query" => $query, "request" => $request, "resourceClass" => SchoolResource::class, "returnName" => "schools"];
        ResponseService::fetchPainateDate($response);
    }

}
