File manager - Edit - /var/www/html/spdc/api/app/Http/Controllers/VolunteerController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\VolunteerRequest; use App\Http\Services\VolunteerService; use App\Models\Volunteer; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; class VolunteerController extends Controller { private VolunteerService $service; public function __construct() { $this->service = new VolunteerService(); } /** * @OA\Get( * path="/api/volunteers", * summary="Get all volunteers", * operationId="GetAllVolunteers", * security={{"bearerAuth":{}}}, * tags={"Volunteers"}, * @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/volunteers", * summary="Add a new volunteer", * operationId="AddNewVolunteer", * security={{"bearerAuth":{}}}, * tags={"Volunteers"}, * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"neighbourhood", "name", "document", "specialty", "contact", "zip_code", "street", "number", "city", "reference"}, * @OA\Property( * property="neighbourhood", * type="string" * ), * @OA\Property( * property="name", * type="string" * ), * @OA\Property( * property="document", * type="string" * ), * @OA\Property( * property="specialty", * type="string", * ), * @OA\Property( * property="contact", * type="string", * ), * @OA\Property( * property="zip_code", * type="string", * ), * @OA\Property( * property="street", * type="string", * ), * @OA\Property( * property="number", * type="string", * ), * @OA\Property( * property="city", * type="string", * ), * @OA\Property( * property="reference", * type="string", * ), * @OA\Property( * property="is_whatsapp", * type="boolean", * ), * @OA\Property( * property="notes", * type="string", * ), * @OA\Property( * property="nupdec_id", * type="string", * ), * ), * ) * ), * @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(VolunteerRequest $request): JsonResponse { $response = $this->service->store($request); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/volunteer/{id}", * summary="Get details from a volunteer", * operationId="GetVolunteerDetails", * security={{"bearerAuth":{}}}, * tags={"Volunteers"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Volunteer 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="Volunteer not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Volunteer 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(Volunteer $volunteer): JsonResponse { $response = $this->service->show($volunteer); return response()->json($response->data, $response->code); } /** * @OA\Patch( * path="/api/volunteer/{id}", * summary="Update a volunteer", * operationId="UpdateVolunteer", * security={{"bearerAuth":{}}}, * tags={"Volunteers"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Volunteer ID", * @OA\Schema(type="string") * ), * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"neighbourhood", "name", "document", "specialty", "contact", "zip_code", "street", "number", "city", "reference"}, * @OA\Property( * property="neighbourhood", * type="string" * ), * @OA\Property( * property="name", * type="string" * ), * @OA\Property( * property="document", * type="string" * ), * @OA\Property( * property="specialty", * type="string" * ), * @OA\Property( * property="contact", * type="string" * ), * @OA\Property( * property="zip_code", * type="string" * ), * @OA\Property( * property="street", * type="string" * ), * @OA\Property( * property="number", * type="string" * ), * @OA\Property( * property="city", * type="string" * ), * @OA\Property( * property="reference", * type="string" * ), * @OA\Property( * property="is_whatsapp", * type="boolean" * ), * @OA\Property( * property="notes", * type="string" * ), * @OA\Property( * property="nupdec_id", * 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="Volunteer not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Volunteer 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."), * ) * ), * @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."), * ) * ) * ) * ) */ 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/volunteer/{id}", * summary="Delete a volunteer", * operationId="DeleteVolunteer", * security={{"bearerAuth":{}}}, * tags={"Volunteers"}, * @OA\Parameter( * name="id", * in="path", * required=true, * description="Volunteer 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="Volunteer not found", * @OA\JsonContent( * @OA\Property(property="data", type="json", example="{}"), * @OA\Property(property="message", type="string", example="Volunteer 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.01 |
proxy
|
phpinfo
|
Settings