Implement project board status workflow
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class MoveProjectTicketRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
/** @var Project $project */
|
||||
$project = $this->route('project');
|
||||
|
||||
return [
|
||||
'board_column_id' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
Rule::exists('board_columns', 'id')->where('project_id', $project->id),
|
||||
],
|
||||
'redirect_to' => ['required', 'string', Rule::in(['backlog', 'board'])],
|
||||
];
|
||||
}
|
||||
|
||||
public function boardColumnId(): ?int
|
||||
{
|
||||
$boardColumnId = $this->validated('board_column_id');
|
||||
|
||||
if ($boardColumnId === null || $boardColumnId === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $boardColumnId;
|
||||
}
|
||||
|
||||
public function redirectRouteName(): string
|
||||
{
|
||||
return $this->validated('redirect_to') === 'backlog'
|
||||
? 'projects.backlog.index'
|
||||
: 'projects.board.index';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user