'datetime', ]; /** * Get the user that owns the stats. */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get the game for the stats (if per-game). */ public function game(): BelongsTo { return $this->belongsTo(Game::class); } /** * Custom method to update stats after a game play (example). * * @param float $betAmount * @param float $winAmount */ public function updateAfterPlay(float $betAmount, float $winAmount): void { $this->increment('play_count'); $this->total_bets += $betAmount; $this->total_winnings += $winAmount; $this->daily_play_amount += $betAmount; // Simplify; use cron for daily reset $this->win_streak = $winAmount > 0 ? $this->win_streak + 1 : 0; $this->last_played_at = now(); $this->save(); } }