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); + } }