Add application API and OpenAPI docs
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\ProjectBoard;
|
||||
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class StoreBoardColumn
|
||||
{
|
||||
use ReordersBoardColumns;
|
||||
|
||||
/**
|
||||
* @param array{name: string, position?: int|null} $validated
|
||||
*/
|
||||
public function handle(Project $project, array $validated): BoardColumn
|
||||
{
|
||||
$desiredPosition = Arr::get($validated, 'position') ?? $project->boardColumns()->count() + 1;
|
||||
|
||||
return DB::transaction(function () use ($project, $validated, $desiredPosition): BoardColumn {
|
||||
$boardColumn = $project->boardColumns()->create([
|
||||
'name' => Arr::get($validated, 'name'),
|
||||
'position' => $project->boardColumns()->count() + 1,
|
||||
]);
|
||||
$boardColumn->ticketStatuses()->create([
|
||||
'name' => Arr::get($validated, 'name'),
|
||||
'position' => 1,
|
||||
'project_id' => $project->id,
|
||||
]);
|
||||
|
||||
$this->reorderColumns($project, $boardColumn, $desiredPosition);
|
||||
|
||||
return $boardColumn;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user