1 | <?php |
||
10 | class BroadcastNotificationCreated implements ShouldBroadcast |
||
11 | { |
||
12 | use SerializesModels; |
||
13 | |||
14 | /** |
||
15 | * The notifiable entity who received the notification. |
||
16 | * |
||
17 | * @var mixed |
||
18 | */ |
||
19 | public $notifiable; |
||
20 | |||
21 | /** |
||
22 | * The notification instance. |
||
23 | * |
||
24 | * @var \Illuminate\Notifications\Notification |
||
25 | */ |
||
26 | public $notification; |
||
27 | |||
28 | /** |
||
29 | * The notification data. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | public $data = []; |
||
34 | |||
35 | /** |
||
36 | * Create a new event instance. |
||
37 | * |
||
38 | * @param mixed $notifiable |
||
39 | * @param \Illuminate\Notifications\Notification $notification |
||
40 | * @param array $data |
||
41 | * @return void |
||
|
|||
42 | */ |
||
43 | 1 | public function __construct($notifiable, $notification, $data) |
|
49 | |||
50 | /** |
||
51 | * Get the channels the event should broadcast on. |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | public function broadcastOn() |
||
59 | |||
60 | /** |
||
61 | * Get the data that should be sent with the broadcasted event. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | public function broadcastWith() |
||
66 | { |
||
67 | return array_merge($this->data, [ |
||
68 | 'id' => $this->notification->id, |
||
69 | 'type' => get_class($this->notification), |
||
70 | ]); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Get the broadcast channel name for the event. |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | protected function channelName() |
||
84 | } |
||
85 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.