]> git.localhorst.tv Git - alttp.git/blob - app/Models/GuessingWinner.php
adlib chat
[alttp.git] / app / Models / GuessingWinner.php
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Broadcasting\Channel as PublicChannel;
6 use Illuminate\Broadcasting\PrivateChannel;
7 use Illuminate\Database\Eloquent\BroadcastsEvents;
8 use Illuminate\Database\Eloquent\Factories\HasFactory;
9 use Illuminate\Database\Eloquent\Model;
10
11 class GuessingWinner extends Model {
12
13         use BroadcastsEvents;
14         use HasFactory;
15
16         public function channel() {
17                 return $this->belongsTo(Channel::class);
18         }
19
20         public function broadcastOn($event) {
21                 $channels = [
22                         new PrivateChannel('Channel.'.$this->channel_id),
23                 ];
24                 if (!empty($this->channel->access_key)) {
25                         $channels[] = new PublicChannel('ChannelKey.'.$this->channel->access_key);
26                 }
27                 return $channels;
28         }
29
30 }