Skip to content

Commit f41d248

Browse files
committed
2 parents ae4f72d + 6b32086 commit f41d248

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,19 @@ Add the routes to your `web.php` file:
6666
```php
6767
use Vormkracht10\FilamentMails\Facades\FilamentMails;
6868

69+
// Basic usage - uses default Filament panel path and name
6970
FilamentMails::routes();
71+
72+
// Prefix routes with path and/or name
73+
FilamentMails::routes(
74+
path: 'panel-path',
75+
name: 'filament.panel'
76+
);
7077
```
7178

79+
> [!NOTE]
80+
> By default, the path will be set to your Filament panel's path and the name will be 'filament.' followed by your panel's ID. You only need to customize these if you want different values.
81+
7282
Then add the plugin to your `PanelProvider`
7383

7484
```php

src/FilamentMails.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,30 @@
88

99
class FilamentMails
1010
{
11-
public static function routes()
11+
protected static string $path;
12+
13+
protected static string $name;
14+
15+
public static function setPath(?string $path = null): void
16+
{
17+
static::$path = $path ?? filament()->getDefaultPanel()->getPath();
18+
}
19+
20+
public static function setName(?string $name = null): void
1221
{
13-
Route::get('mails/{mail}/preview', MailPreviewController::class)->name('mails.preview');
14-
Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)->name('mails.attachment.download');
22+
static::$name = $name ?? 'filament.' . filament()->getDefaultPanel()->getId() . '.';
23+
}
24+
25+
public static function routes(?string $path = null, ?string $name = null): void
26+
{
27+
static::setPath($path);
28+
static::setName($name);
29+
30+
Route::prefix(static::$path)
31+
->name(static::$name)
32+
->group(function () {
33+
Route::get('mails/{mail}/preview', MailPreviewController::class)->name('mails.preview');
34+
Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)->name('mails.attachment.download');
35+
});
1536
}
1637
}

0 commit comments

Comments
 (0)