Files
ots/app/Http/Requests/UpdateTeamRequest.php
T
Twyco f9958fb7cf
CI/CD / test_and_check_app (push) Failing after 55s
CI/CD / Publish immutable image (push) Skipped
show slug in form
2026-09-19 02:06:54 +02:00

42 lines
1.0 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
class UpdateTeamRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' => ['nullable', 'string', 'max:255'],
'slug' => ['nullable', 'required_with:name', 'string', 'max:255', 'unique:teams,slug,'.$this->route('team')->id],
'require_2fa' => ['required', 'boolean'],
];
}
public function messages(): array
{
return [
'slug.string' => '',
'slug.required' => '',
'slug.max' => '',
'slug.unique' => 'The name has already been taken.',
];
}
protected function prepareForValidation(): void
{
$this->merge([
'slug' => Str::slug($this->name),
]);
}
}