User Notifications in Livewire with Megaphone

  • Reading time ~ 2 min
  • 08.10.2022
Megaphone is a Livewire UI for Laravel-based user notifications. It uses built-in Laravel notification features to allow you to add bell icons to your Livewire app.

Megaphone is a Livewire UI for Laravel-based user notifications. It uses built-in Laravel notification features to allow you to add bell icons to your Livewire app:

use MBarlow\Megaphone\Types\Important;
use App\Models\User;
 
$notification = new Important(
    // Notification Title
    'Expected Downtime!',
    // Notification Body
    'We are expecting some downtime today at around 15:00 UTC for some planned maintenance. Read more on a blog post!',
    'https://example.com/link', // Optional
    'Read More...' // Optional
);
 
$user->notify($notification);

Using the above code, you can render notifications in your app using the provided Blade component:

<livewire:megaphone></livewire:megaphone>

This package has other neat features to manage notifications and send them en masse to users:

  • Custom notification types
  • Command to clear announcements
  • Customizable list of notification types in the admin panel
  • Admin panel to send notifications to all users
  • Livewire component to render the admin panel

You can learn more about this package, get full installation instructions, and view the source code on GitHub.


This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Original
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

I'm full stack laravel developer

I knew my call in programming back in 2006.

WORK EXPERIENCE
CONTACT
Ukraine, Lutsk
+380979856297