Skip to content

Commit

Permalink
add hook to configure broadcastable model event
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 21, 2021
1 parent f4bb259 commit 5ca5768
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Illuminate/Database/Eloquent/BroadcastsEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function broadcastIfBroadcastChannelsExistForEvent($instance, $event,
*/
public function newBroadcastableModelEvent($event)
{
return tap(new BroadcastableModelEventOccurred($this, $event), function ($event) {
return tap($this->withBroadcastableEvent(new BroadcastableModelEventOccurred($this, $event)), function ($event) {
$event->connection = property_exists($this, 'broadcastConnection')
? $this->broadcastConnection
: $this->broadcastConnection();
Expand All @@ -139,6 +139,17 @@ public function newBroadcastableModelEvent($event)
});
}

/**
* Configure the broadcastable model event for the model.
*
* @param \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred $event
* @return \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred
*/
protected function withBroadcastableEvent(BroadcastableModelEventOccurred $event)
{
return $event;
}

/**
* Get the channels that model events should broadcast on.
*
Expand Down

0 comments on commit 5ca5768

Please sign in to comment.