refresh(); $user->balance = $newBalance; $user->save(); }); Log::info("GameService: Synced User {$user->id} balance to $newBalance"); } // Track wagering if applicable if ($wager > 0) { $this->bonusService->trackWagering($user, (float) $wager); } // Log bet if info is available if (isset($data['bet']) || isset($data['win'])) { $this->logBet($user, $data); } } /** * Log a game bet into the database */ protected function logBet(User $user, array $data): void { try { GameBet::create([ 'user_id' => $user->id, 'game_name' => $data['game'] ?? 'Unknown', 'wager_amount' => $data['bet'] ?? 0, 'payout_amount' => $data['win'] ?? 0, 'payout_multiplier' => ($data['bet'] > 0) ? ($data['win'] / $data['bet']) : 0, 'currency' => 'BTX' ]); } catch (\Exception $e) { Log::error("GameService: Failed to log bet: " . $e->getMessage()); } } }