Files
bogazici-api/app/Http/Requests/Role/UpdateRoleRequest.php
2026-03-27 10:41:54 +03:00

40 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Requests\Role;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateRoleRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, array<int, mixed>>
*/
public function rules(): array
{
return [
'name' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('roles', 'name')->ignore($this->route('role'))],
'permissions' => ['sometimes', 'required', 'array', 'min:1'],
'permissions.*' => ['string', 'exists:permissions,name'],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'name.required' => 'Rol adı zorunludur.',
'name.unique' => 'Bu rol adı zaten kullanılıyor.',
'permissions.min' => 'En az bir yetki seçilmelidir.',
'permissions.*.exists' => 'Geçersiz yetki.',
];
}
}