-
Create a componet notification.blade.php
-
Add to your layout
<x-notification />
-
Add Macro to your AppServiceProvider.php
-
Call Macro $this->notify('Some Message', 'Yeah Baby!', 'success');
Options:
- $this->notify('You saved something.'); //Default Success Toast NO TITLE
- $this->notify('You saved something.', 'Success!'); //Default Success Toast WITH TITLE
- $this->notify('You have amessage', 'Message', ''); //Message Toast WITH TITLE
- $this->notify('You saved something.', 'Yay You!', 'success'); //success Toast WITH TITLE
- $this->notify('Oh No', 'There was a problem', 'error'); //Error Toast WITH TITLE
- $this->notify('You can't do that...', 'Warning...', 'warning'); //Warning Toast WITH TITLE
- $this->notify('Here's Something New!', 'New Product', 'info'); //Info Toast WITH TITLE
I have something similar I'm using (I didn't abstract it in the Service Provider, nice touch!) - but for any notifications that happen after a redirect, I had to duplicate this and call it via flash session data. Any ideas on how to get it to work with both? My initial thought was to look for the flash notification on page load, and fire a browser event, but that didn't go well.