Last active
August 24, 2023 09:28
-
-
Save RikoDEV/7ec6feaee359bcf8ee8c2c6f78d8951a to your computer and use it in GitHub Desktop.
Trigger Laravel Jetstream banner from Livewire component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Success banner | |
$this->dispatchBrowserEvent('banner-message', [ | |
'style' => 'success', | |
'message' => 'Amazing success banner!' | |
]); | |
// Danger banner | |
$this->dispatchBrowserEvent('banner-message', [ | |
'style' => 'danger', | |
'message' => 'Mysterious danger banner!' | |
]); |
Holy crap thank you
Thanks!
@RikoDEV @iammuttaqi
If you're using Jetstream, you can use the Laravel\Jetstream\InteractsWithBanner
trait in your Livewire component and just call banner($message)
or dangerBanner($message)
.
How I know? I implemented it using your snippet and when I wanted to import the trait I wrote, two traits showed up, the one I wrote and the one that already comes with Jetstream. :-)
Laravel\Jetstream\InteractsWithBanner
Legend!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💝