1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace App\Events;
use Pusher\Pusher;
class NotificationEvent
{
private $pusher;
private $options = array();
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
$this->options["cluster"] = env("PUSHER_APP_CLUSTER");
$this->options["useTLS"] = true;
$this->pusher = new Pusher(
env("PUSHER_APP_KEY"),
env("PUSHER_APP_SECRET"),
env("PUSHER_APP_ID"),
$this->options
);
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function trigger($channelName, $eventName, $data){
$this->pusher->trigger($channelName,$eventName,$data);
}
}