Skip to content

Commit 4227bd7

Browse files
committed
rename method
1 parent 6626512 commit 4227bd7

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php

+13-15
Original file line numberDiff line numberDiff line change
@@ -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
}

tests/Notifications/NotificationBroadcastChannelTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testNotificationIsBroadcastedWithCustomEventName()
5252
$notifiable, $notification, $notification->toArray($notifiable)
5353
);
5454

55-
$eventName = $event->broadcastAs();
55+
$eventName = $event->broadcastType();
5656

5757
$this->assertSame('custom.type', $eventName);
5858
}
@@ -115,7 +115,7 @@ public function toArray($notifiable)
115115
return ['invoice_id' => 1];
116116
}
117117

118-
public function broadcastAs()
118+
public function broadcastType()
119119
{
120120
return 'custom.type';
121121
}

0 commit comments

Comments
 (0)