Added quiz new features

This commit is contained in:
m.razaghi
2026-08-20 16:21:03 +03:30
parent 7cb3978775
commit 76d9246e0e
8 changed files with 156 additions and 18 deletions

32
app/Events/MatchEnded.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MatchEnded implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $matchId;
public function __construct($matchId)
{
$this->matchId = $matchId;
}
public function broadcastOn()
{
// ارسال پیام به کانال پرایوت بازی که هر دو نفر داخل آن هستند
return new PrivateChannel('pvp-match.' . $this->matchId);
}
public function broadcastAs()
{
return 'match.ended';
}
}