Skip to content

Commit 62102ef

Browse files
committed
document customizing model broadcasting event creation
1 parent d036931 commit 62102ef

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

broadcasting.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,28 @@ public function broadcastOn($event)
838838
}
839839
```
840840

841+
<a name="customizing-model-broadcasting-event-creation"></a>
842+
#### Customizing Model Broadcasting Event Creation
843+
844+
Occasionally, you may wish to customize how Laravel creates the underlying model broadcasting event. You may accomplish this by defining a `newBroadcastableEvent` method on your Eloquent model. This method should return an `Illuminate\Database\Eloquent\BroadcastableModelEventOccurred` instance:
845+
846+
```php
847+
use Illuminate\Database\Eloquent\BroadcastableModelEventOccurred
848+
849+
/**
850+
* Create a new broadcastable model event for the model.
851+
*
852+
* @param string $event
853+
* @return \Illuminate\Database\Eloquent\BroadcastableModelEventOccurred
854+
*/
855+
protected function newBroadcastableEvent($event)
856+
{
857+
return (new BroadcastableModelEventOccurred(
858+
$this, $event
859+
))->dontBroadcastToCurrentUser();
860+
}
861+
```
862+
841863
<a name="model-broadcasting-conventions"></a>
842864
### Model Broadcasting Conventions
843865

0 commit comments

Comments
 (0)