<?php

namespace App\Http\Requests\Admin;

use Illuminate\Validation\Rule;
use App\Http\Requests\ApiFormRequest;

final class AdminRoleUpdateRequest extends ApiFormRequest
{
    public function authorize(): bool
    {
        return true;
    }

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

        return [
            'slug' => ['sometimes', 'string', 'max:64', 'regex:/^[a-z0-9_\\-]+$/', Rule::unique('admin_roles', 'slug')->ignore($roleId)],
            'name' => ['sometimes', 'string', 'max:128'],
            'description' => ['nullable', 'string', 'max:65535'],
            'status' => ['sometimes', 'integer', 'in:0,1'],
        ];
    }
}
