<?php

namespace App\Filament\Support;

use App\Filament\Resources\Concerns\HasModulePermissions;
use Illuminate\Support\Facades\Auth;

/**
 * Single call site for "{module_key}.{action}" permission checks outside the
 * standard CRUD verbs already covered by {@see HasModulePermissions}
 * (.void, .export, .approve, etc. — see permissions.md). Wraps the same
 * User::hasPermissionTo() the source app's CheckPermission middleware and
 * HasModulePermissions both call — no new authorization logic, just a
 * convenient call site for ad hoc Action ->visible()/->authorize() closures.
 */
class Perm
{
    public static function can(string $moduleKey, string $action): bool
    {
        return Auth::user()?->hasPermissionTo("{$moduleKey}.{$action}") ?? false;
    }
}
