<?php

namespace Modules\Canteen\Controllers\Api;

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

use Modules\Canteen\Models\Canteen;
use Modules\Canteen\Resources\Api\CanteenResource;
use Modules\Canteen\Services\CanteenService;
class CanteenController extends Controller
{

    public function __construct(
        private CanteenService $canteenService,
    ) {
    }

    /**
     * Get Canteen.
     *
     * @param Request $request
     * @param Canteen $canteen
     * @return JsonResponse
     */
    public function show(Request $request, Canteen $canteen): JsonResponse
    {
        $credentials = $request->only('title');
        $credentials['api'] = true;
        $query = $this->canteenService->get($credentials);

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

}
