Files
2026-09-06 03:55:24 +08:00

47 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Concerns;
use App\Models\Admin;
use App\Models\User;
use App\Models\WalletMnemonic;
trait RevealsMnemonics
{
protected function canRevealMnemonics(): bool
{
if ($this->isAgentPortal()) {
$agent = $this->agent();
return $agent instanceof User && $agent->canRevealMnemonics();
}
$admin = auth('admin')->user();
return $admin instanceof Admin && $admin->canRevealMnemonics();
}
protected function googleBoundForReveal(): bool
{
if ($this->isAgentPortal()) {
$agent = $this->agent();
return $agent instanceof User && $agent->hasGoogleBound();
}
$admin = auth('admin')->user();
return $admin instanceof Admin && $admin->hasGoogleBound();
}
protected function mnemonicRevealUrl(int|string|WalletMnemonic $mnemonic): string
{
return route($this->portal().'.mnemonics.reveal', $mnemonic);
}
protected function google2faUrl(): string
{
return route($this->portal().'.security.google2fa');
}
}