File manager - Edit - /var/www/html/pcadigital/api/app/Http/Controllers/CommentController.php
Back
<?php namespace App\Http\Controllers; use App\Http\Requests\CommentRequest; use App\Http\Services\CommentService; use App\Models\Comment; /** * @OA\Tag( * name="Comment", * description="Gerenciamento de Comments" * ) */ class CommentController extends Controller { private CommentService $commentService; public function __construct() { $this->commentService = new CommentService(); } /** * @OA\Get( * path="/api/comments", * summary="Lista Comments", * operationId="IndexComment", * tags={"Comment"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=200, description="Comments retornados com sucesso") * ) */ public function index() { $response = $this->commentService->index(); return response()->json($response->data, $response->code); } /** * @OA\Get( * path="/api/comments/{comment}", * summary="Mostra Comment", * operationId="ShowComment", * tags={"Comment"}, * security={{"bearerAuth":{}}}, * @OA\Parameter( * name="comment", * in="path", * required=true, * @OA\Schema(type="integer") * ), * @OA\Response(response=200, description="Comment retornado com sucesso"), * @OA\Response(response=404, description="Comment não encontrado") * ) */ public function show(Comment $comment) { $response = $this->commentService->show($comment); return response()->json($response->data, $response->code); } /** * @OA\Post( * path="/api/comments", * summary="Cria Comment", * operationId="StoreComment", * tags={"Comment"}, * security={{"bearerAuth":{}}}, * @OA\Response(response=201, description="Comment criado com sucesso"), * @OA\Response(response=422, description="Erro de validação") * ) */ public function store(CommentRequest $request) { $response = $this->commentService->store($request); return response()->json($response->data, $response->code); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings