<?php

namespace Modules\Identity\Filament\Resources\Roles\Pages;

use Filament\Resources\Pages\EditRecord;
use Modules\Identity\Filament\Resources\Roles\RoleResource;
use Spatie\Permission\PermissionRegistrar;

class EditRole extends EditRecord
{
    protected static string $resource = RoleResource::class;

    protected function getHeaderActions(): array
    {
        // No DeleteAction — the role set is fixed (see RoleResource docblock).
        return [];
    }

    /**
     * Spatie caches resolved permissions per-request/process — without
     * this, a permission just toggled here wouldn't take effect until the
     * cache naturally expires (RolePermissionSeeder does the same flush).
     */
    protected function afterSave(): void
    {
        app(PermissionRegistrar::class)->forgetCachedPermissions();
    }
}
