diff --git a/README.md b/README.md index 65c188eb..d6f0c18a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ php artisan vendor:publish --tag="filament-help-config" This is the contents of the published config file: ```php + \Tapp\FilamentHelp\Models\HelpArticle::class, + /* + |-------------------------------------------------------------------------- + | Frontend Configuration + |-------------------------------------------------------------------------- + | + | Configure the frontend help article resource behaviour. + | + */ + + 'frontend' => [ + 'resource' => [ + /* + * Whether the frontend Help resource appears in the panel navigation. + * Set to false to hide from the topbar and use a custom link (e.g. in the user menu) instead. + */ + 'should_register_navigation' => true, + ], + ], + /* |-------------------------------------------------------------------------- | Tenancy Configuration diff --git a/config/filament-help.php b/config/filament-help.php index b030686a..4f203b2b 100644 --- a/config/filament-help.php +++ b/config/filament-help.php @@ -17,6 +17,25 @@ 'model' => \Tapp\FilamentHelp\Models\HelpArticle::class, + /* + |-------------------------------------------------------------------------- + | Frontend Configuration + |-------------------------------------------------------------------------- + | + | Configure the frontend help article resource behaviour. + | + */ + + 'frontend' => [ + 'resource' => [ + /* + * Whether the frontend Help resource appears in the panel navigation. + * Set to false to hide from the topbar and use a custom link (e.g. in the user menu) instead. + */ + 'should_register_navigation' => true, + ], + ], + /* |-------------------------------------------------------------------------- | Tenancy Configuration diff --git a/src/Resources/Frontend/HelpArticleResource.php b/src/Resources/Frontend/HelpArticleResource.php index bf5fc2d4..27de6053 100644 --- a/src/Resources/Frontend/HelpArticleResource.php +++ b/src/Resources/Frontend/HelpArticleResource.php @@ -3,6 +3,7 @@ namespace Tapp\FilamentHelp\Resources\Frontend; use Filament\Actions\ViewAction; +use Filament\Facades\Filament; use Filament\Resources\Resource; use Filament\Support\Enums\Alignment; use Filament\Tables\Columns\Layout\Stack; @@ -26,12 +27,13 @@ public static function getModel(): string public static function shouldRegisterNavigation(): bool { - // Only register navigation if we're on the app panel and routes exist - $panel = \Filament\Facades\Filament::getCurrentPanel(); - if ($panel && $panel->getId() === 'app') { - return true; + if (! config('filament-help.frontend.resource.should_register_navigation', true)) { + return false; } - return false; + + $panel = Filament::getCurrentPanel(); + + return $panel && $panel->getId() === 'app'; } protected static ?string $modelLabel = 'Help Article'; @@ -103,7 +105,7 @@ public static function getEloquentQuery(): \Illuminate\Database\Eloquent\Builder // Apply tenant scoping if enabled if (config('filament-help.tenancy.enabled', false) && config('filament-help.tenancy.scoping.frontend', true)) { - $tenant = \Filament\Facades\Filament::getTenant(); + $tenant = Filament::getTenant(); if ($tenant) { $tenantColumn = config('filament-help.tenancy.column') ?? 'team_id'; $query->where($tenantColumn, $tenant->id);