@@ -64,17 +64,19 @@ public function broadcastOn()
6464 }
6565
6666 /**
67- * Get the type of the broadcasted event.
67+ * Get the broadcast channel name for the event.
6868 *
6969 * @return string
7070 */
71- public function broadcastAs ()
71+ protected function channelName ()
7272 {
73- if (method_exists ($ this ->notification , 'broadcastAs ' )) {
74- return $ this ->notification -> broadcastAs ( );
73+ if (method_exists ($ this ->notifiable , 'receivesBroadcastNotificationsOn ' )) {
74+ return $ this ->notifiable -> receivesBroadcastNotificationsOn ( $ this -> notification );
7575 }
7676
77- return get_class ($ this ->notification );
77+ $ class = str_replace ('\\' , '. ' , get_class ($ this ->notifiable ));
78+
79+ return $ class .'. ' .$ this ->notifiable ->getKey ();
7880 }
7981
8082 /**
@@ -86,23 +88,19 @@ public function broadcastWith()
8688 {
8789 return array_merge ($ this ->data , [
8890 'id ' => $ this ->notification ->id ,
89- 'type ' => $ this ->broadcastAs (),
91+ 'type ' => $ this ->broadcastType (),
9092 ]);
9193 }
9294
9395 /**
94- * Get the broadcast channel name for the event .
96+ * Get the type of the notification being broadcast .
9597 *
9698 * @return string
9799 */
98- protected function channelName ()
100+ public function broadcastType ()
99101 {
100- if (method_exists ($ this ->notifiable , 'receivesBroadcastNotificationsOn ' )) {
101- return $ this ->notifiable ->receivesBroadcastNotificationsOn ($ this ->notification );
102- }
103-
104- $ class = str_replace ('\\' , '. ' , get_class ($ this ->notifiable ));
105-
106- return $ class .'. ' .$ this ->notifiable ->getKey ();
102+ return method_exists ($ this ->notification , 'broadcastType ' )
103+ ? $ this ->notification ->broadcastType ()
104+ : get_class ($ this ->notification );
107105 }
108106}
0 commit comments