Files
test_polis/laravel/app/Http/Controllers/CommentController.php
2026-02-04 23:23:42 +07:00

75 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Http\Requests\StoreCommentRequest;
use App\Http\Requests\UpdateCommentRequest;
use App\Http\Resources\CommentResource;
use App\Models\Article;
use App\Models\Comment;
use Illuminate\Http\JsonResponse;
final class CommentController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*/
public function store(StoreCommentRequest $request, Article $article): JsonResponse
{
$comment = $article->comments()->create($request->validated())->fresh();
return new CommentResource($comment)->response()
->setStatusCode(201);
}
/**
* Display the specified resource.
*/
public function show(Comment $comment)
{
//
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Comment $comment)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateCommentRequest $request, Comment $comment)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Comment $comment)
{
//
}
}