<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateRoleRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $roleId = $this->route('role');

        return [
            'name' => 'sometimes|required|string|max:255|unique:roles,name,'.$roleId,
            'display_name' => 'sometimes|required|string|max:255',
            'description' => 'nullable|string|max:1000',
            'guard_name' => 'nullable|string|max:50',
            'permissions' => 'nullable|array',
            'permissions.*' => 'integer|exists:permissions,id',
        ];
    }
}
