forgetAgents(); }; static::saved($bust); static::deleted($bust); } protected function casts(): array { return [ 'password' => 'hashed', 'status' => 'integer', 'auto_transfer_enabled' => 'boolean', 'auto_transfer_threshold_usdt' => 'decimal:8', 'auto_transfer_threshold_trx' => 'decimal:8', 'auto_transfer_threshold_eth' => 'decimal:8', 'auto_transfer_threshold_btc' => 'decimal:8', ]; } public function isEnabled(): bool { return (int) $this->status === 1; } public function channels(): HasMany { return $this->hasMany(Channel::class, 'user_id'); } public function hasTelegramChat(): bool { return trim((string) ($this->chat_id ?? '')) !== ''; } /** @deprecated Use hasTelegramChat(); kept for existing call sites. */ public function hasTelegramBot(): bool { return $this->hasTelegramChat(); } public static function findEnabledByChatId(int|string|null $chatId): ?self { $chatId = trim((string) $chatId); if ($chatId === '') { return null; } return static::query() ->where('status', 1) ->where('chat_id', $chatId) ->orderBy('id') ->first(); } }