Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Feb 7, 2025
2 parents ae4f72d + 6b32086 commit f41d248
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ Add the routes to your `web.php` file:
```php
use Vormkracht10\FilamentMails\Facades\FilamentMails;

// Basic usage - uses default Filament panel path and name
FilamentMails::routes();

// Prefix routes with path and/or name
FilamentMails::routes(
path: 'panel-path',
name: 'filament.panel'
);
```

> [!NOTE]
> 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.
Then add the plugin to your `PanelProvider`

```php
Expand Down
27 changes: 24 additions & 3 deletions src/FilamentMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@

class FilamentMails
{
public static function routes()
protected static string $path;

protected static string $name;

public static function setPath(?string $path = null): void
{
static::$path = $path ?? filament()->getDefaultPanel()->getPath();
}

public static function setName(?string $name = null): void
{
Route::get('mails/{mail}/preview', MailPreviewController::class)->name('mails.preview');
Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)->name('mails.attachment.download');
static::$name = $name ?? 'filament.' . filament()->getDefaultPanel()->getId() . '.';
}

public static function routes(?string $path = null, ?string $name = null): void
{
static::setPath($path);
static::setName($name);

Route::prefix(static::$path)
->name(static::$name)
->group(function () {
Route::get('mails/{mail}/preview', MailPreviewController::class)->name('mails.preview');
Route::get('mails/{mail}/attachment/{attachment}/{filename}', MailDownloadController::class)->name('mails.attachment.download');
});
}
}

0 comments on commit f41d248

Please sign in to comment.