Files
KanbanGit/app/Http/Requests/DeleteProjectRequest.php
T
Twyco 09f695a9bc
CI/CD / preconditions (pull_request) Successful in 2s
CI/CD / test_and_check_app (pull_request) Failing after 1m52s
CI/CD / Publish immutable image (pull_request) Skipped
fix: allow project admins to delete projects (KAN-64)
2026-09-30 11:01:04 +02:00

44 lines
986 B
PHP

<?php
namespace App\Http\Requests;
use App\Models\Project;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class DeleteProjectRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()?->can('admin-project', $this->route('project')) ?? false;
}
/**
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
/** @var Project $project */
$project = $this->route('project');
return [
'confirmation_key' => [
'required',
'string',
Rule::in([$project->key]),
],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'confirmation_key.in' => 'Enter the exact project key to confirm deletion.',
];
}
}