File manager - Edit - /var/www/html/spdc/api/app/Http/Controllers/OccurrencyScriptureController.php
Back
<?php namespace App\Http\Controllers; use App\Models\Occurrency; use Illuminate\Http\Request; use Illuminate\Http\JsonResponse; use App\Models\OccurrencyScripture; use App\Classes\BaseServiceResponse; use Illuminate\Support\Facades\Validator; use App\Http\Services\OccurrencyScriptureService; class OccurrencyScriptureController extends Controller { private OccurrencyScriptureService $scriptureService; public function __construct() { $this->scriptureService = new OccurrencyScriptureService(); $this->middleware('auth.permissions:gestao-de-ocorrencias'); } /** * @OA\Get( * path="/api/occurrency-scripture/list/{occurrency_id}", * summary="List all scriptures from an occurrency", * description="List all scriptures from an occurrency", * operationId="GetAllScripturesFromOccurrency", * security={{"bearerAuth":{}}}, * tags={"occurrency_scriptures"}, * @OA\Parameter( * name="occurrency_id", * in="path", * required=true, * description="Occurrency 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="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * @OA\Response( * response="404", * description="Not found", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Not found."), * ) * ), * ) */ public function listByOccurrency(Occurrency $occurrency): JsonResponse { return $this->response($this->scriptureService->listByOccurrency($occurrency)); } /** * @OA\Post( * path="/api/occurrency-scripture/sign/{scripture_id}", * summary="Sign a scripture", * description="Sign a scripture", * operationId="SignScripture", * security={{"bearerAuth":{}}}, * tags={"occurrency_scriptures"}, * @OA\Parameter( * name="scripture_id", * in="path", * required=true, * description="Scripture ID", * @OA\Schema(type="string") * ), * @OA\RequestBody( * required=true, * @OA\MediaType( * mediaType="application/x-www-form-urlencoded", * @OA\Schema( * required={"document","name","signature_file"}, * @OA\Property( * property="document", * type="string", * description="Cpf or Cnpj" * ), * @OA\Property( * property="name", * type="string", * description="Name" * ), * @OA\Property( * property="email", * type="string", * description="Email" * ), * @OA\Property( * property="signature_file", * type="file", * description="Signature file" * ), * ), * ), * @OA\MediaType( * mediaType="application/json", * @OA\Schema( * required={"document","name","signature_file"}, * @OA\Property( * property="document", * type="string", * description="Cpf or Cnpj" * ), * @OA\Property( * property="name", * type="string", * description="Name" * ), * @OA\Property( * property="email", * type="string", * description="Email" * ), * @OA\Property( * property="signature_file", * type="file", * description="Signature file" * ), * ), * ), * ), * @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="401", * description="Unauthorized", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Unauthorized."), * ) * ), * @OA\Response( * response="404", * description="Not found", * @OA\JsonContent( * @OA\Property(property="message", type="string", example="Not found."), * ) * ), * ) */ public function sign(Request $request, OccurrencyScripture $scripture): JsonResponse { $validator = Validator::make($request->all(), [ 'document' => ['required', 'cpf_ou_cnpj'], 'name' => ['required', 'max:255'], 'email' => ['required', 'email'], 'signature_file' => ['required'] ]); if ($validator->fails()) { return $this->response(new BaseServiceResponse( JsonResponse::HTTP_UNPROCESSABLE_ENTITY, $validator->errors()->toArray(), __('general.validation_error') )); } return $this->response($this->scriptureService->sign($request, $scripture)); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings