File manager - Edit - /var/www/html/spdc/api/app/Http/Controllers/DonationQuestionnaireController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\DonationQuestionnaireRequest; use App\Http\Services\DonationQuestionnaireService; use Illuminate\Http\JsonResponse; class DonationQuestionnaireController extends Controller { private DonationQuestionnaireService $service; public function __construct() { $this->service = new DonationQuestionnaireService(); } /** * @OA\Get( * path="/api/questionnaire/donations", * summary="Get all donation questionnaires", * operationId="GetAllDonationQuestionnaires", * security={{"bearerAuth":{}}}, * tags={"Donation Questionnaires"}, * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ) * ) */ public function index(): JsonResponse { $response = $this->service->index(); return response()->json($response->data, $response->code); } /** * @OA\Post( * path="/api/questionnaire/donations", * summary="Create a new donation questionnaire", * operationId="CreateDonationQuestionnaire", * security={{"bearerAuth":{}}}, * tags={"Donation Questionnaires"}, * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"shelter_id", "family_id", "donation"}, * @OA\Property( * property="shelter_id", * type="string", * example="9b6e0239-a7b6-4ce8-a56c-da800fb28f70", * description="ID do abrigo" * ), * @OA\Property( * property="family_id", * type="string", * example="9b6e0332-4ee2-46c4-84b7-4859b3b806fd", * description="ID da familia" * ), * @OA\Property( * property="donation", * type="array", * example="20", * description="Items e quantidade de doacoes", * collectionFormat="multi", * @OA\Items( * @OA\Property( * property="name", * type="string", * description="nome da doacao" * ), * @OA\Property( * property="quantity", * type="string", * description="quantidade de doacoes" * ), * ), * ), * ) * ) * ), * @OA\Response( * response="201", * description="Created", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success.") * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized.") * ) * ), * @OA\Response( * response="400", * description="Bad request", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Bad request") * ) * ) * ) */ public function store(DonationQuestionnaireRequest $request): JsonResponse { $response = $this->service->store($request); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/questionnaire/donations/{id}", * summary="Get a specific donation questionnaire", * operationId="GetDonationQuestionnaire", * security={{"bearerAuth":{}}}, * tags={"Donation Questionnaires"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="ID of the donation questionnaire", * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="Successful operation", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="404", * description="Donation questionnaire not found", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Donation questionnaire not found") * ) * ) * ) */ public function show(string $id): JsonResponse { $response = $this->service->show($id); return response()->json($response->data, $response->code); } /** * @OA\Put( * path="/api/questionnaire/donations/{id}", * summary="Update a donation questionnaire", * operationId="UpdateDonationQuestionnaire", * security={{"bearerAuth":{}}}, * tags={"Donation Questionnaires"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="ID of the donation questionnaire", * @OA\Schema(type="string") * ), * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"shelter_id", "family_id", "donation"}, * @OA\Property( * property="shelter_id", * type="string", * example="9b6e0239-a7b6-4ce8-a56c-da800fb28f70", * description="ID do abrigo" * ), * @OA\Property( * property="family_id", * type="string", * example="9b6e0332-4ee2-46c4-84b7-4859b3b806fd", * description="ID da familia" * ), * @OA\Property( * property="donation", * type="array", * example="20", * description="Items e quantidade de doacoes", * collectionFormat="multi", * @OA\Items( * @OA\Property( * property="name", * type="string", * description="nome da doacao" * ), * @OA\Property( * property="quantity", * type="string", * description="quantidade de doacoes" * ), * ), * ), * ) * ) * ), * @OA\Response( * response="200", * description="Successful operation", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success.") * ) * ), * @OA\Response( * response="404", * description="Donation questionnaire not found", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Donation questionnaire not found") * ) * ) * ) */ public function update(DonationQuestionnaireRequest $request, string $id): JsonResponse { $response = $this->service->update($request, $id); return response()->json($response->data, $response->code); } /** * @OA\Delete( * path="/api/questionnaire/donations/{id}", * summary="Delete a donation questionnaire", * operationId="DeleteDonationQuestionnaire", * security={{"bearerAuth":{}}}, * tags={"Donation Questionnaires"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="ID of the donation questionnaire", * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="Successful operation", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="404", * description="Donation questionnaire not found", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Donation questionnaire not found") * ) * ) * ) */ public function destroy(string $id): JsonResponse { $response = $this->service->delete($id); return response()->json($response->data, $response->code); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings