Files
Vari fa3d97354b More work on the Matchmaking logic
Now players get added to the queue and the controller tries to create matches when enough matching players are in the Queue.
2024-03-09 12:26:15 +01:00

46 lines
858 B
PHP

<?php
namespace App\Models\Game\Matchmaking;
use App\Enums\Game\Matchmaking\MatchmakingSide;
use App\Models\User\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @mixin IdeHelperQueuedPlayer
*/
class QueuedPlayer extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'side',
];
protected $casts = [
'side' => MatchmakingSide::class,
];
protected static function boot()
{
parent::boot();
}
public function user()
{
return $this->belongsTo(User::class);
}
public function followingUsers()
{
return $this->hasMany(QueuedPlayer::class, 'queued_player_id');
}
public function leader()
{
return $this->belongsTo(QueuedPlayer::class, 'queued_player_id');
}
}