Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ php artisan vendor:publish --tag="filament-help-config"
This is the contents of the published config file:

```php
<?php

return [

/*
Expand All @@ -47,6 +49,25 @@ return [

'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
Expand Down
19 changes: 19 additions & 0 deletions config/filament-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/Resources/Frontend/HelpArticleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down Expand Up @@ -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);
Expand Down