Files
ots/app/Http/Requests/StoreTeamRequest.php
T
Twyco e9fc8cabb5
CI/CD / test_and_check_app (push) Failing after 58s
CI/CD / Publish immutable image (push) Skipped
Fix team authorization, invite revocation, and slug handling
2026-09-19 05:54:18 +02:00

42 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
class StoreTeamRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['required', 'string', 'max:255'],
'slug' => ['required', 'string', 'max:255', Rule::notIn(['create']), Rule::unique('teams', 'slug')],
'require_2fa' => ['required', 'boolean'],
];
}
public function messages(): array
{
return [
'slug.required' => 'The name must contain letters or numbers.',
'slug.not_in' => 'This name is reserved.',
'slug.unique' => 'The name has already been taken.',
];
}
protected function prepareForValidation(): void
{
$this->merge([
'slug' => is_string($this->input('name')) ? Str::slug($this->input('name')) : null,
]);
}
}