Skip to content

Commit fb156b6

Browse files
scott graysonscott grayson
authored andcommitted
Update guest panel resource to support nullable slug and fix logout route handling
1 parent 9c2d02a commit fb156b6

File tree

10 files changed

+17
-103
lines changed

10 files changed

+17
-103
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ public function panel(Panel $panel): Panel
6565
return $panel
6666
// ...
6767
->plugins([
68-
FilamentHelpFrontendPlugin::make()
69-
->slug('app/help'), // Optional: customize the URL slug
70-
//...
68+
FilamentHelpFrontendPlugin::make(),
69+
// Default slug is 'help-articles', so articles will be at {panel-path}/help-articles
70+
// Customize with ->slug('custom-slug') if needed
7171
]);
7272
}
7373
```
7474

7575
**Configuration Options:**
76-
- **Plugin method**: `->slug('custom-slug')` - Set the URL slug when registering the plugin (defaults to `'help'` if not specified)
76+
- **Plugin method**: `->slug('custom-slug')` - Set the URL slug when registering the plugin (defaults to `'help-articles'` if not specified)
7777

78-
**Location**: App panel (defaults to `/help`, configurable via `->slug()`)
78+
**Location**: App panel (defaults to `{panel-path}/help-articles`, configurable via `->slug()`)
7979
**Access**: Authenticated users only
8080
**Features**: Read-only access to public help articles
8181

@@ -114,8 +114,8 @@ public function panel(Panel $panel): Panel
114114
Help articles are available in three different locations depending on your setup:
115115

116116
1. **Admin Panel** (`/admin/help-articles`): For editing and managing help articles
117-
2. **App Panel** (configurable, default `/help`): For authenticated users to view public help articles
118-
3. **Guest Panel** (configurable, default uses panel path): For public/guest users to view public help articles
117+
2. **App Panel** (configurable, default `{panel-path}/help-articles`): For authenticated users to view public help articles
118+
3. **Guest Panel** (configurable, default `{panel-path}/help`): For public/guest users to view public help articles
119119

120120
The frontend and guest panel URLs can be customized using the plugin's `->slug()` method when registering the plugin (see plugin documentation above).
121121

config/filament-help.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

resources/views/pages/list-help.blade.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

resources/views/pages/view-help.blade.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

resources/views/resources/guest/help-article-resource/pages/view-help-article.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@
2727
</x-filament-panels::page>
2828

2929

30+

src/FilamentHelpFrontendPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function getId(): string
2828

2929
public function register(Panel $panel): void
3030
{
31-
// Set the slug on the resource - use provided slug or default to 'help'
32-
$defaultSlug = 'help';
31+
// Set the slug on the resource - use provided slug or default to 'help-articles'
32+
$defaultSlug = 'help-articles';
3333
$slug = $this->slug ?? $defaultSlug;
3434

3535
if (empty($slug)) {

src/FilamentHelpGuestPlugin.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public function register(Panel $panel): void
3232
$defaultSlug = 'help';
3333
$slug = $this->slug ?? $defaultSlug;
3434

35-
if (empty($slug)) {
36-
throw new \InvalidArgumentException('Slug cannot be empty. Please provide a non-empty slug when registering the plugin.');
35+
// Allow empty slug only if explicitly passed (to use panel path directly)
36+
// But default must always be non-empty
37+
if ($slug === $defaultSlug && empty($slug)) {
38+
throw new \InvalidArgumentException('Default slug cannot be empty. Please provide a non-empty slug when registering the plugin.');
3739
}
3840

3941
\Tapp\FilamentHelp\Resources\Guest\HelpArticleResource::setSlug($slug);

src/FilamentHelpServiceProvider.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public function configurePackage(Package $package): void
1313
$package
1414
->name('filament-help')
1515
->hasViews()
16-
->hasConfigFile('filament-help')
1716
->hasMigrations([
1817
'create_help_articles_table',
1918
'add_is_hidden_to_help_articles_table',
@@ -24,17 +23,4 @@ public function configurePackage(Package $package): void
2423
->askToRunMigrations();
2524
});
2625
}
27-
28-
public function boot(): void
29-
{
30-
parent::boot();
31-
32-
$this->publishes([
33-
__DIR__.'/../../resources/views' => resource_path('views/vendor/filament-help'),
34-
], 'filament-help-views');
35-
36-
$this->publishes([
37-
__DIR__.'/../resources/css/help.css' => public_path('vendor/filament-help/help.css'),
38-
], 'filament-help-assets');
39-
}
4026
}

src/Resources/Frontend/HelpArticleResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function shouldRegisterNavigation(): bool
2727

2828
protected static ?string $modelLabel = 'Help Article';
2929

30-
protected static string $slug = 'help';
30+
protected static ?string $slug = 'help-articles';
3131

3232
public static function setSlug(string $slug): void
3333
{

src/Resources/Guest/HelpArticleResource.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ public static function shouldRegisterNavigation(): bool
2727

2828
protected static ?string $modelLabel = 'Help Article';
2929

30-
protected static string $slug = 'help';
30+
protected static ?string $slug = 'help';
3131

3232
public static function setSlug(string $slug): void
3333
{
34-
if (empty($slug)) {
35-
throw new \InvalidArgumentException('Slug cannot be empty.');
36-
}
37-
34+
// Allow empty string to use panel path directly (when explicitly set)
3835
static::$slug = $slug;
3936
}
4037

0 commit comments

Comments
 (0)