Add application API and OpenAPI docs
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Actions\Permissions\PermissionService;
|
||||
use App\Actions\Projects\BuildProjectBacklogPayload;
|
||||
use App\Actions\Projects\BuildProjectBoardPayload;
|
||||
use App\Enums\Permission;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProjectBoardController extends ApiController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BuildProjectBacklogPayload $buildProjectBacklogPayload,
|
||||
private readonly BuildProjectBoardPayload $buildProjectBoardPayload,
|
||||
private readonly PermissionService $permissionService,
|
||||
) {}
|
||||
|
||||
public function board(Request $request, Project $project): JsonResponse
|
||||
{
|
||||
$user = $this->authenticatedUser($request);
|
||||
|
||||
abort_unless(
|
||||
$this->permissionService->allows($user, Permission::ProjectRead, $project),
|
||||
403,
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'data' => $this->buildProjectBoardPayload->handle($project, $user),
|
||||
]);
|
||||
}
|
||||
|
||||
public function backlog(Request $request, Project $project): JsonResponse
|
||||
{
|
||||
$user = $this->authenticatedUser($request);
|
||||
|
||||
abort_unless(
|
||||
$this->permissionService->allows($user, Permission::ProjectRead, $project),
|
||||
403,
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'data' => $this->buildProjectBacklogPayload->handle($project, $user),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user