| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Http\Controllers;
- use App\Services\KanbanReplyService;
- use App\Http\Requests\KanbanReplyRequest;
- use App\Http\Resources\KanbanReplyResource;
- use Illuminate\Http\JsonResponse;
- class KanbanReplyController extends Controller
- {
- public function __construct(
- protected KanbanReplyService $service,
- ) {}
- public function index(int $kanbanId): JsonResponse
- {
- $replies = $this->service->getByKanban($kanbanId);
- return $this->successResponse(payload: KanbanReplyResource::collection($replies));
- }
- public function store(KanbanReplyRequest $request, int $kanbanId): JsonResponse
- {
- $reply = $this->service->create($kanbanId, auth()->id(), $request->validated()['reply']);
- return $this->successResponse(payload: new KanbanReplyResource($reply), message: __('messages.created'), code: 201);
- }
- public function update(KanbanReplyRequest $request, int $kanbanId, int $id): JsonResponse
- {
- $reply = $this->service->update($kanbanId, $id, $request->validated()['reply']);
- return $this->successResponse(payload: new KanbanReplyResource($reply), message: __('messages.updated'));
- }
- public function destroy(int $kanbanId, int $id): JsonResponse
- {
- $this->service->delete($kanbanId, $id);
- return $this->successResponse(message: __('messages.deleted'), code: 204);
- }
- }
|