<?php

namespace App\Support;

use App\Models\AdminRole;
use App\Models\AdminUser;
use Illuminate\Validation\ValidationException;

final class AdminAccountScopeGuard
{
    public static function assertPlatformAccount(AdminUser $user): void
    {
        if ($user->isAgentAccount()) {
            throw ValidationException::withMessages([
                'admin_user' => [trans('admin.agent_account_managed_in_agents')],
            ]);
        }
    }

    public static function assertSystemRole(AdminRole $role): void
    {
        if (($role->scope_type ?? AdminRole::SCOPE_SYSTEM) !== AdminRole::SCOPE_SYSTEM) {
            throw ValidationException::withMessages([
                'admin_role' => [trans('admin.agent_role_managed_in_agents')],
            ]);
        }
    }
}
