]> git.localhorst.tv Git - alttp.git/blob - routes/channels.php
switch muffinstracker to autotracking branch
[alttp.git] / routes / channels.php
1 <?php
2
3 use App\Models\Channel;
4 use App\Models\Tournament;
5 use Illuminate\Support\Facades\Broadcast;
6
7 /*
8 |--------------------------------------------------------------------------
9 | Broadcast Channels
10 |--------------------------------------------------------------------------
11 |
12 | Here you may register all of the event broadcasting channels that your
13 | application supports. The given channel authorization callbacks are
14 | used to check if an authenticated user can listen to the channel.
15 |
16 */
17
18 Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
19         return (int) $user->id === (int) $id;
20 });
21
22 Broadcast::channel('App.Control', function ($user) {
23         return true;
24 });
25
26 Broadcast::channel('Channel.{id}', function ($user, $id) {
27         $channel = Channel::findOrFail($id);
28         return $user->can('editRestream', $channel);
29 });
30
31 Broadcast::channel('Protocol.{id}', function ($user, $id) {
32         $tournament = Tournament::findOrFail($id);
33         return $user->can('viewProtocol', $tournament);
34 });
35
36 Broadcast::channel('Tournament.{id}', function ($user, $id) {
37         $tournament = Tournament::findOrFail($id);
38         return true;
39 });