From 0d26ebff46316bdcbe8a8898c616ddf64fb442e7 Mon Sep 17 00:00:00 2001 From: FoxRocks76 Date: Wed, 8 Sep 2021 14:43:10 -0400 Subject: [PATCH 1/2] Update building-your-app.md Adding some information on how to access the banner message inline, as opposed to through the request. I spent a lot of time looking for this solution and wanted to share it for the rest of the newbies :) --- 2.x/building-your-app.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/2.x/building-your-app.md b/2.x/building-your-app.md index 07bdfd2..455d9b5 100644 --- a/2.x/building-your-app.md +++ b/2.x/building-your-app.md @@ -65,3 +65,19 @@ $request->session()->flash('flash.bannerStyle', 'success'); return redirect('/'); ``` + +You can also hook into the banner inline without having to use the request: + +```php +public function cancel($name) +{ + $cancelled = Auth::user()->currentTeam->subscription($name)->cancel(); + + if($cancelled->ends_at){ + return redirect()->route('subscriptions')->banner('Subscriptions successfully cancelled!'); + } + else{ + return redirect()->route('subscriptions')->dangerBanner('Subscriptions not cancelled!'); + } +} +``` From aa182e20dfaaf4b7f80e39d0df629ace886f6072 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 9 Sep 2021 08:06:34 -0500 Subject: [PATCH 2/2] Update building-your-app.md --- 2.x/building-your-app.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/2.x/building-your-app.md b/2.x/building-your-app.md index 455d9b5..31cf4bb 100644 --- a/2.x/building-your-app.md +++ b/2.x/building-your-app.md @@ -66,18 +66,10 @@ $request->session()->flash('flash.bannerStyle', 'success'); return redirect('/'); ``` -You can also hook into the banner inline without having to use the request: +You may also instruct Jetstream to display the banner by invoking the `banner` or `dangerBanner` methods on a redirect response instance: ```php -public function cancel($name) -{ - $cancelled = Auth::user()->currentTeam->subscription($name)->cancel(); - - if($cancelled->ends_at){ - return redirect()->route('subscriptions')->banner('Subscriptions successfully cancelled!'); - } - else{ - return redirect()->route('subscriptions')->dangerBanner('Subscriptions not cancelled!'); - } -} +return redirect()->route('subscriptions')->banner('Subscription created successfully.'); + +return redirect()->route('subscriptions')->dangerBanner('Subscription cancellation failed.'); ```