Added casino interface, wallet login, sucessful npm build sucessfull container build
This commit is contained in:
70
app/Models/PlayerStats.php
Normal file
70
app/Models/PlayerStats.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PlayerStats extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'game_id',
|
||||
'total_winnings',
|
||||
'total_bets',
|
||||
'play_count',
|
||||
'daily_play_amount',
|
||||
'win_streak',
|
||||
'last_played_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'last_played_at' => '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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user