diff --git a/src/InteractsWithBanner.php b/src/InteractsWithBanner.php index b2bec9b1b..ddb131a38 100644 --- a/src/InteractsWithBanner.php +++ b/src/InteractsWithBanner.php @@ -19,7 +19,21 @@ protected function banner($message) } /** - * Update the banner message with an danger / error message. + * Update the banner message with a warning message. + * + * @param string $message + * @return void + */ + protected function warningBanner($message) + { + $this->dispatch('banner-message', + style: 'warning', + message: $message, + ); + } + + /** + * Update the banner message with a danger / error message. * * @param string $message * @return void diff --git a/src/JetstreamServiceProvider.php b/src/JetstreamServiceProvider.php index d81c26beb..720706409 100644 --- a/src/JetstreamServiceProvider.php +++ b/src/JetstreamServiceProvider.php @@ -61,6 +61,14 @@ public function boot() ]); }); + RedirectResponse::macro('warningBanner', function ($message) { + /** @var \Illuminate\Http\RedirectResponse $this */ + return $this->with('flash', [ + 'bannerStyle' => 'warning', + 'banner' => $message, + ]); + }); + RedirectResponse::macro('dangerBanner', function ($message) { /** @var \Illuminate\Http\RedirectResponse $this */ return $this->with('flash', [ diff --git a/stubs/livewire/resources/views/components/banner.blade.php b/stubs/livewire/resources/views/components/banner.blade.php index ffd33f9e8..b45c25d1e 100644 --- a/stubs/livewire/resources/views/components/banner.blade.php +++ b/stubs/livewire/resources/views/components/banner.blade.php @@ -1,7 +1,7 @@ @props(['style' => session('flash.bannerStyle', 'success'), 'message' => session('flash.banner')])
- + @@ -22,6 +22,10 @@ + + + +

@@ -31,7 +35,7 @@