Skip to content

Commit

Permalink
Merge pull request #36 from Geoffry304/main
Browse files Browse the repository at this point in the history
Bug fix when using in tenant environment
  • Loading branch information
pxlrbt authored Dec 21, 2023
2 parents ce2aa3f + a025728 commit 4001546
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/SpotlightPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace pxlrbt\FilamentSpotlight;

use Filament\Contracts\Plugin;
use Filament\Events\TenantSet;
use Filament\Facades\Filament;
use Filament\Panel;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Event;
use pxlrbt\FilamentSpotlight\Actions\RegisterPages;
use pxlrbt\FilamentSpotlight\Actions\RegisterResources;
use pxlrbt\FilamentSpotlight\Actions\RegisterUserMenu;
Expand All @@ -28,19 +30,31 @@ public function register(Panel $panel): void
{
$panel->renderHook(
'panels::scripts.after',
fn () => Blade::render("@livewire('livewire-ui-spotlight')")
fn() => Blade::render("@livewire('livewire-ui-spotlight')")
);
}

public function boot(Panel $panel): void
{
Filament::serving(function () use ($panel) {
config()->set('livewire-ui-spotlight.include_js', false);
if (Filament::hasTenancy()) {
Event::listen(TenantSet::class, function () use ($panel) {
self::registerNavigation($panel);
});
} else {
self::registerNavigation($panel);
}


RegisterPages::boot($panel);
RegisterResources::boot($panel);
RegisterUserMenu::boot($panel);
});

}

public static function registerNavigation($panel)
{
RegisterPages::boot($panel);
RegisterResources::boot($panel);
RegisterUserMenu::boot($panel);
}
}

0 comments on commit 4001546

Please sign in to comment.