Skip to content

Commit

Permalink
add global switch
Browse files Browse the repository at this point in the history
  • Loading branch information
drjamesj committed Jul 6, 2024
1 parent cdd1d36 commit 074bdc3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions config/livewire-beacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

return [

/*
|--------------------------------------------------------------------------
| Beacon Enabled
|--------------------------------------------------------------------------
|
| This option controls whether or not Beacon is enabled.
|
*/

'enabled' => true,

/*
|--------------------------------------------------------------------------
| Beacon Channel
Expand Down
4 changes: 4 additions & 0 deletions src/LivewireBeacon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class LivewireBeacon

public static function livewireBeaconScripts($expression)
{
if (! config('livewire-beacon.enabled', true)) {
return;
}

return '{!! \Executable\LivewireBeacon\LivewireBeacon::scripts('.$expression.') !!}';
}

Expand Down
8 changes: 6 additions & 2 deletions src/LivewireBeaconServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ public function configurePackage(Package $package): void

public function packageBooted()
{
Blade::directive('livewireBeaconScripts', [LivewireBeacon::class, 'livewireBeaconScripts']);

if (! config('livewire-beacon.enabled', true)) {
return;
}

Event::listen(
MessageReceived::class,
ReverbMessageReceivedListener::class,
);

Blade::directive('livewireBeaconScripts', [LivewireBeacon::class, 'livewireBeaconScripts']);

$route = Route::get(
config('app.debug') ? '/livewire/beacon.js' : 'livewire/beacon.min.js',
[LivewireBeacon::class, 'returnJavascriptAsFile']
Expand Down

0 comments on commit 074bdc3

Please sign in to comment.