Skip to content

Commit 0b29e75

Browse files
authored
Merge pull request #72 from backstagephp/fix/auto-register-mail-routes
fix: auto-register mail routes in plugin
2 parents 90d473b + 8f12135 commit 0b29e75

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,7 @@ Optionally, you can publish the views using
6262
php artisan vendor:publish --tag="mails-views"
6363
```
6464

65-
Add the routes to the PanelProvider using the `routes()` method, like this:
66-
67-
```php
68-
use Backstage\Mails\Facades\Mails;
69-
70-
public function panel(Panel $panel): Panel
71-
{
72-
return $panel
73-
->routes(fn () => Mails::routes());
74-
}
75-
```
76-
77-
Then add the plugin to your `PanelProvider`
65+
Add the plugin to your `PanelProvider`
7866

7967
```php
8068
use Backstage\Mails\MailsPlugin;
@@ -118,22 +106,6 @@ $panel
118106

119107
This example demonstrates how to combine role-based and permission-based access control, providing a more robust and flexible approach to managing access to mail resources.
120108

121-
### Tenant middleware and route protection
122-
123-
If you want to protect the mail routes with your (tenant) middleware, you can do so by adding the routes to the `tenantRoutes`:
124-
125-
```php
126-
use Backstage\Mails\MailsPlugin;
127-
use Backstage\Mails\Facades\Mails;
128-
129-
public function panel(Panel $panel): Panel
130-
{
131-
return $panel
132-
->plugin(MailsPlugin::make())
133-
->tenantRoutes(fn() => Mails::routes());
134-
}
135-
```
136-
137109
> [!IMPORTANT]
138110
> For setting up the webhooks to register mail events, please look into the README of [Laravel Mails](https://github.com/backstagephp/laravel-mails), the underlying package that powers this package.
139111

src/MailsPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public function register(Panel $panel): void
3232
config('mails.resources.mail', MailResource::class),
3333
config('mails.resources.event', EventResource::class),
3434
config('mails.resources.suppression', SuppressionResource::class),
35-
]);
35+
])
36+
->routes(fn () => Mails::routes())
37+
->tenantRoutes(fn () => Mails::routes());
3638
}
3739

3840
public function boot(Panel $panel): void

0 commit comments

Comments
 (0)