Skip to content

Commit

Permalink
Merge pull request #43 from savannabits/3.x-dev
Browse files Browse the repository at this point in the history
Fix: Moved sidebar hooks to the register function after filament has been resolved.
  • Loading branch information
coolsam726 committed Jul 25, 2023
2 parents f208240 + 8ccc22c commit 1847f36
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/ModulesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,23 @@ public function register()
{
$this->app->register(LaravelModulesServiceProvider::class);
$this->app->singleton('coolsam-modules', Modules::class);
$this->app->afterResolving('filament', function () {
foreach (Filament::getPanels() as $panel) {
$id = \Str::of($panel->getId());
if ($id->contains('::')) {
$title = $id->replace(['::', '-'], [' ', ' '])->title()->toString();
$panel
->renderHook(
'sidebar.start',
fn () => new HtmlString("<h2 class='m-2 p-2 font-black text-xl'>$title</h2>"),
)->renderHook(
'sidebar.end',
fn () => new HtmlString("<a href='".url('/')."' class='m-2 p-2 block rounded-lg font-bold bg-primary-500/10 text-primary-500'>Go to Home</a>"),
);
}
}
});

return parent::register();
}

public function callBootedCallbacks()
{
foreach (Filament::getPanels() as $panel) {
$id = \Str::of($panel->getId());
if ($id->contains('::')) {
$title = $id->replace(['::', '-'], [' ', ' '])->title()->toString();
$panel
->renderHook(
'sidebar.start',
fn () => new HtmlString("<h2 class='m-2 p-2 font-black text-xl'>$title</h2>"),
)->renderHook(
'sidebar.end',
fn () => new HtmlString("<a href='".url('/')."' class='m-2 p-2 block rounded-lg font-bold bg-primary-500/10 text-primary-500'>Go to Home</a>"),
);
}
}
parent::callBootedCallbacks(); // TODO: Change the autogenerated stub
}
}

0 comments on commit 1847f36

Please sign in to comment.