mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-31 05:16:49 -04:00
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
/**
|
|
* Class UserEvent
|
|
*/
|
|
class UserEvent implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
public $data;
|
|
private $userIds;
|
|
|
|
/**
|
|
* Create a new event instance.
|
|
*
|
|
* @param array $data
|
|
* @param int|array $userIds
|
|
*/
|
|
public function __construct($data, $userIds)
|
|
{
|
|
$this->data = $data;
|
|
$this->userIds = $userIds;
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
|
|
*/
|
|
public function broadcastOn()
|
|
{
|
|
$channels = [];
|
|
|
|
if (is_array($this->userIds)) {
|
|
foreach ($this->userIds as $userId) {
|
|
array_push($channels, new PrivateChannel('user.'.$userId));
|
|
}
|
|
|
|
return $channels;
|
|
}
|
|
|
|
return new PrivateChannel('user.'.$this->userIds);
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function broadcastWith()
|
|
{
|
|
return $this->data;
|
|
}
|
|
}
|