first commit
This commit is contained in:
74
laravel/app/Http/Controllers/CommentController.php
Normal file
74
laravel/app/Http/Controllers/CommentController.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user