File manager - Edit - /var/www/html/spdc/api/app/Http/Controllers/NupdecController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\NupdecRequest; use App\Http\Services\NupdecService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class NupdecController extends Controller { private NupdecService $service; public function __construct() { $this->service = new NupdecService(); } /** * @OA\Get( * path="/api/nupdecs", * summary="Get all donation nupdecs", * operationId="GetAllNupedecs", * security={{"bearerAuth":{}}}, * tags={"Nupdecs"}, * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ) * ) */ /** * Display a listing of the resource. * * @return \Illuminate\Http\JsonResponse */ public function index(): JsonResponse { $response = $this->service->index(); return response()->json($response->data, $response->code); } /** * @OA\Post( * path="/api/nupedecs", * summary="Adiciona novo Nupedec", * description="", * operationId="AddNewNupedec", * security={{"bearerAuth":{}}}, * tags={"nupedecs"}, * @OA\RequestBody( * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"neighborhood"}, * @OA\Property( * property="neighborhood", * type="string" * ), * @OA\Property( * property="notes", * type="string" * ), * @OA\Property( * property="is_active", * type="boolean" * ), * @OA\Property( * property="volunteers", * type="array", * collectionFormat="multi", * @OA\Items( * @OA\Property( * property="id", * type="string", * description="ID do voluntario" * ), * @OA\Property( * property="nupdec_id", * type="string", * description="ID do nupdec" * ), * ), * ), * ), * ), * ), * @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=400, * description="Bad Request", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Bad Request."), * ) * ), * @OA\Response( * response=401, * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * ) */ public function store(NupdecRequest $request): JsonResponse { $response = $this->service->store($request); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/nupdec/{id}", * summary="Get details from a nupdec", * operationId="GetNupdecDetails", * security={{"bearerAuth":{}}}, * tags={"Nupdecs"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Nupdec ID", * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="404", * description="Nupdec not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Nupdec not found") * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ) * ) */ public function show(string $id): JsonResponse { $response = $this->service->show($id); return response()->json($response->data, $response->code); } /** * @OA\Put( * path="/api/nupdec/{id}", * summary="Update a nupdec", * operationId="UpdateNupdec", * security={{"bearerAuth":{}}}, * tags={"Nupdecs"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Nupdec ID", * @OA\Schema(type="string") * ), * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"neighborhood"}, * @OA\Property( * property="neighborhood", * type="string" * ), * @OA\Property( * property="notes", * type="string" * ), * @OA\Property( * property="is_active", * type="boolean" * ), * @OA\Property( * property="volunteers", * type="array", * collectionFormat="multi", * @OA\Items( * @OA\Property( * property="id", * type="string", * description="ID do voluntario" * ), * @OA\Property( * property="nupdec_id", * type="string", * description="ID do nupdec" * ), * ), * ) * ) * ) * ), * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="404", * description="Nupdec not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Nupdec not found") * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ) * ) */ public function update(Request $request, string $id): JsonResponse { $response = $this->service->update($request, $id); return response()->json($response->data, $response->code); } /** * @OA\Delete( * path="/api/nupdec/{id}", * summary="Delete a nupdec", * operationId="DeleteNupdec", * security={{"bearerAuth":{}}}, * tags={"Nupdecs"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Nupdec ID", * @OA\Schema(type="string") * ), * @OA\Response( * response="200", * description="OK", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Success."), * ) * ), * @OA\Response( * response="404", * description="Nupdec not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Nupdec not found") * ) * ), * @OA\Response( * response="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ) * ) */ 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