]> git.localhorst.tv Git - alttp.git/blobdiff - app/Events/UserChanged.php
allow users to set their stream link
[alttp.git] / app / Events / UserChanged.php
diff --git a/app/Events/UserChanged.php b/app/Events/UserChanged.php
new file mode 100644 (file)
index 0000000..9009c44
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace App\Events;
+
+use App\Models\User;
+use Illuminate\Broadcasting\Channel;
+use Illuminate\Broadcasting\InteractsWithSockets;
+use Illuminate\Broadcasting\PresenceChannel;
+use Illuminate\Broadcasting\PrivateChannel;
+use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
+use Illuminate\Foundation\Events\Dispatchable;
+use Illuminate\Queue\SerializesModels;
+
+class UserChanged implements ShouldBroadcast
+{
+       use Dispatchable, InteractsWithSockets, SerializesModels;
+
+       /**
+        * Create a new event instance.
+        *
+        * @return void
+        */
+       public function __construct(User $user)
+       {
+               $this->user = $user;
+       }
+
+       /**
+        * Get the channels the event should broadcast on.
+        *
+        * @return \Illuminate\Broadcasting\Channel|array
+        */
+       public function broadcastOn()
+       {
+               return [
+                       new Channel('App.Control'),
+                       new PrivateChannel('App.Models.User.'.$this->user->id),
+               ];
+       }
+
+       public $user;
+
+}