<?php
 namespace App\Http\Requests\Admin\RoleManagement; use Illuminate\Foundation\Http\FormRequest; class RoleManagementStoreRequest extends FormRequest { public function authorize(): bool { return $this->user()->can('create', \Spatie\Permission\Models\Role::class); } public function rules(): array { return [ 'name' => 'required|string|max:255|unique:roles,name', 'guard_name' => 'nullable|string|in:admin,web', 'permissions' => 'nullable|array', 'permissions.*' => 'string|exists:permissions,name', ]; } public function messages(): array { return [ 'name.required' => __('admin/validation.role_management_name_required'), 'name.unique' => __('admin/validation.role_management_name_unique'), 'permissions.*.exists' => __('admin/validation.role_management_permissions_exists'), ]; } } 