mattlibera / livewire-flash

A Laravel Livewire-based Flash message component
MIT License
118 stars 17 forks source link

[Request] Add a group (or bag) property to container #12

Open vtalbot opened 3 years ago

vtalbot commented 3 years ago

Hi, nice package!

I think there should be a group property to allow different flash messages at different places.

mattlibera commented 3 years ago

Good suggestion. I think we could accomplish this using differently-named "bags", similar to error bags. I could envision allowing a user to pass in a bag name to the Livewire component, with a fallback to the default:

<livewire:flash-container bag="secondary"> <!-- would give the user any flash notifications in the 'secondary' bag -->

<livewire:flash-container> <!-- would give the user any flash notifications in the 'default' bag --> 
<livewire:flash-container bag="default"> <!-- would give the user any flash notifications in the 'default' bag -->

API could be:

flash('message')->info()->livewire($this); // default bag

flash('message')->info()->bag('secondary')->livewire($this); // 'secondary' bag

I'll chew on this a bit more but this seems pretty attainable at first ponder. Feel free to PR it! 😉