Files
KanbanGit/app/Http/Requests/ProjectSettingsRequest.php
T
Twyco ff796aa10a
linter / quality (pull_request) Successful in 1m28s
tests / ci (8.4) (pull_request) Successful in 1m47s
feat: overhaul project workspace navigation
2026-07-18 17:52:25 +02:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests;
use App\Enums\ProjectSettingsSection;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
class ProjectSettingsRequest 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
{
return [
'section' => ['required', Rule::enum(ProjectSettingsSection::class)],
];
}
protected function prepareForValidation(): void
{
$section = Arr::get($this->query(), 'section');
$this->merge([
'section' => is_string($section) && ProjectSettingsSection::tryFrom($section) !== null
? $section
: ProjectSettingsSection::General->value,
]);
}
}