From d579f1ad6a1b56e1f00f42a2165d8cd5aef0ca26 Mon Sep 17 00:00:00 2001 From: Luis Dalmolin Date: Fri, 23 Aug 2019 07:48:14 -0300 Subject: [PATCH] Added the ability to disable broadcasting --- published/config.stub | 7 +++++++ src/LockEvent.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/published/config.stub b/published/config.stub index 082e8cc..38fc972 100644 --- a/published/config.stub +++ b/published/config.stub @@ -66,4 +66,11 @@ return [ Sofa\ModelLocking\ModelLocked::class => null, Sofa\ModelLocking\ModelUnlocked::class => null, ], + + /* + |-------------------------------------------------------------------------- + | Determine if the package should broadcast events. + |-------------------------------------------------------------------------- + */ + 'broadcast_enabled' => env('MODEL_LOCKING_BROADCAST_ENABLED', true), ]; diff --git a/src/LockEvent.php b/src/LockEvent.php index 06a3722..d9d6bbb 100644 --- a/src/LockEvent.php +++ b/src/LockEvent.php @@ -49,4 +49,14 @@ public function broadcastAs() { return config('model_locking.broadcast_as.'.static::class) ?: static::class; } + + /** + * Determine if this event should broadcast. + * + * @return bool + */ + public function broadcastWhen() + { + return config('model_locking.broadcast_enabled', true); + } }