Skip to content

Commit 2f09cd8

Browse files
committed
feat: update billing middleware
1 parent f256600 commit 2f09cd8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/docs/utils/billing.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ Leaf billing comes with a middleware that you can use to protect your routes bas
563563
| `billing.subscribed:plan-name` | Protect a route to only allow users subscribed to a specific plan |
564564
| `billing.not-subscribed` | Protect a route to only allow users who aren't subscribed |
565565
| `billing.not-subscribed:plan-name` | Protect a route to only allow users not subscribed to a specific plan |
566-
| `billing.trial` | Protect a route to only allow users on a trial period |
567-
| `billing.not-trial` | Protect a route to only allow users not on a trial period |
566+
<!-- | `billing.trial` | Protect a route to only allow users on a trial period |
567+
| `billing.not-trial` | Protect a route to only allow users not on a trial period | -->
568568

569569
You can use these middlewares in your routes like this:
570570

@@ -577,7 +577,7 @@ app()->get('/protected', [
577577
]);
578578

579579
app()->get('/protected', [
580-
'middleware' => 'billing.not-subscribed',
580+
'middleware' => 'billing.not-subscribed:Starter',
581581
'SubscriptionController@subscribe'
582582
]);
583583
```
@@ -586,10 +586,21 @@ If you want to customize what the middleware does if the user is not allowed to
586586

587587
```php:no-line-numbers [index.php]
588588
billing()->middleware('billing.subscribed', function () {
589-
response()->redirect('/billing/subscribe');
589+
response()->redirect('/some-special-page');
590590
});
591591
```
592592

593+
And then you can use the middleware like this:
594+
595+
```php [_some-route.php]
596+
app()->get('/protected', [
597+
'middleware' => 'billing.subscribed',
598+
function() {
599+
return 'You are subscribed';
600+
}
601+
]);
602+
```
603+
593604
<!-- ## Billing Currency
594605
595606
PayStack is only available in Africa, and relies on local currency. Stripe is available globally and supports multiple currencies, so Leaf's billing allows you to set your currency in your `.env` file.

0 commit comments

Comments
 (0)