File manager - Edit - /var/www/html/pcadigital/api/app/Http/Controllers/HistoricController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\HistoricRequest; use App\Http\Services\HistoricService; use App\Models\Historic; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; /** * @OA\Tag( * name="Historic", * description="Gerenciamento de Histórico de Ocorrências" * ) */ class HistoricController extends Controller { private HistoricService $historicService; public function __construct() { $this->historicService = new HistoricService(); } /** * @OA\Get( * path="/api/occurrence", * summary="Lista históricos", * operationId="IndexHistoric", * tags={"Historic"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=200, description="Históricos retornados com sucesso") * ) */ public function index(): JsonResponse { $response = $this->historicService->index(); return response()->json($response->data, $response->code); } /** * @OA\Post( * path="/api/occurrence", * summary="Cria histórico", * operationId="StoreHistoric", * tags={"Historic"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=201, description="Histórico criado com sucesso"), * @OA\Response(response=422, description="Erro de validação") * ) */ public function store(HistoricRequest $request): JsonResponse { $response = $this->historicService->store($request); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/occurrence/{historic}", * summary="Mostra histórico específico", * operationId="ShowHistoric", * tags={"Historic"}, * security={{"bearerAuth":{}}}, * @OA\Parameter( * name="historic", * in="path", * required=true, * @OA\Schema(type="integer") * ), * @OA\Response(response=200, description="Histórico retornado com sucesso"), * @OA\Response(response=404, description="Histórico não encontrado") * ) */ public function show(Historic $historic): JsonResponse { $response = $this->historicService->show($historic); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/occurrence/status", * summary="Lista possíveis status de histórico", * operationId="HistoricStatus", * tags={"Historic"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=200, description="Status retornados com sucesso") * ) */ public function historicStatus(): JsonResponse { $response = $this->historicService->historicStatus(); return response()->json($response->data, $response->code); } /** * @OA\Patch( * path="/api/occurrence/send-to-citizen", * summary="Marca histórico como enviado ao cidadão", * operationId="SetIsHistoricSendToCitizen", * tags={"Historic"}, * security={{"bearerAuth":{}}}, * @OA\RequestBody( * required=true, * @OA\JsonContent( * required={"status","historic_id"}, * @OA\Property(property="status", type="boolean"), * @OA\Property(property="historic_id", type="integer") * ) * ), * @OA\Response(response=200, description="Indicador atualizado com sucesso"), * @OA\Response(response=422, description="Erro de validação") * ) */ public function setIsHistoricSendToCitizen(Request $request): JsonResponse { $validator = Validator::make($request->all(), [ 'status' => 'required|boolean', 'historic_id' => 'required|exists:historics,id', ]); if ($validator->fails()) { return response()->json( ['errors' => $validator->errors()], JsonResponse::HTTP_UNPROCESSABLE_ENTITY ); } $response = $this->historicService->setSendToCitizen($request); return response()->json($response->data, $response->code); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings