PHPackages                             mbarlow/megaphone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. mbarlow/megaphone

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mbarlow/megaphone
=================

UI and admin for Laravel Notifications.

2.3.0(5mo ago)26477.5k↓16.2%22[3 issues](https://github.com/mikebarlow/megaphone/issues)MITPHPPHP ^8.1CI passing

Since Sep 4Pushed 5mo ago5 watchersCompare

[ Source](https://github.com/mikebarlow/megaphone)[ Packagist](https://packagist.org/packages/mbarlow/megaphone)[ Docs](https://github.com/mikebarlow/megaphone)[ RSS](/packages/mbarlow-megaphone/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (6)Versions (17)Used By (0)

[![](https://raw.githubusercontent.com/mikebarlow/megaphone/main/social-image.png)](https://github.com/mikebarlow/megaphone)

 [![Author](https://camo.githubusercontent.com/9d903e7623152bba92e485dae02e0ffe50922554087701bab4ab685ea10150d2/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d696b656261726c6f772d7265642e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/mikebarlow) [![Latest Version](https://camo.githubusercontent.com/9351a7ee72d9badf09b53d8190df12dd436d38dabecf3671a9dfff5cdd8c23ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d696b656261726c6f772f6d65676170686f6e652e7376673f7374796c653d666c61742d737175617265)](https://github.com/mikebarlow/megaphone/releases) [![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/mikebarlow/megaphone/blob/main/LICENSE) [![Build Status](https://camo.githubusercontent.com/1f3b7a8a410c43a1a91a3df9d9f4a3d118837c716f41d3ba0c0cf5d2ae8f99a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d696b656261726c6f772f6d65676170686f6e652f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/mikebarlow/megaphone/actions)

Megaphone is a Laravel Livewire based component that uses the power of Laravels built in Notifications system to allow you to add "Bell Icon Notification System" to your app.

Megaphone also ships with an Admin form component that allows you to send out a notification to all your users at once. Perfect for announcing new features or planned maintenance!

[![Server Management by ServerAuth.com](https://camo.githubusercontent.com/b2fde40fe08706f6a95d3dd59930a8161a8a44e3b1d0e501e3fb8a86357d319f/68747470733a2f2f736572766572617574682e636f6d2f6173736574732f6d6973632f73706f6e736f722d696d672e706e67)](https://serverauth.com/?utm_campaign=megaphone-sponsor&utm_source=github&utm_medium=readme)

Demo
----

[](#demo)

Before using Megaphone, a demo is available for you to view and try the Bell Icon component and Admin component. Aside from some minor styling changes to the Admin component so it fits the layout better, everything is "out the box" and will be exactly as is when you install Megaphone yourself.

[View the Megaphone Demo](https://megaphone.mikebarlow.co.uk)

Upgrade from 1.x
----------------

[](#upgrade-from-1x)

Megaphone has been updated to support Livewire 3. This also means PHP requirements have been updated to match the requirements of Livewire 3 which means you need to be running PHP 8.1 or above (PHP 7.4 and 8.0 are no longer supported). Then make sure you follow the [Livewire upgrade guide](https://livewire.laravel.com/docs/upgrading).

Update your Megaphone requirement to 2.\* by running the following command in your terminal.

```
    composer require mbarlow/megaphone "^2.0"
```

### AlpineJS

[](#alpinejs)

If you previously included AlpineJS specifically for Megaphone then you can now remove that from your JS include because it is now bundled with Livewire.

### Template Changes

[](#template-changes)

If you are using the Admin component and are running with the Megaphone views published to your resources folder, you may wish to make these manual changes.

Changes are all to `create-announcement.blade.php` which, if published, should be found at `resources/views/vendor/megaphone/admin/create-announcement.blade.php`.

Find `wire:model="type"` and replace it with `wire:model.live="type"`.

Find all instances of `wire:model.lazy` and replace it with `wire:model.blur`.

Installation
------------

[](#installation)

For the Livewire 2 version of Megaphone, see the 1.x versions of Megaphone and the [1.x branch](https://github.com/mikebarlow/megaphone/tree/1.x).

Simply require the package via composer into your Laravel app.

```
composer require mbarlow/megaphone

```

If you aren't already using Laravel Livewire in your app, Megaphone should include the package via its dependency. Once composer has finished installing, make sure you run the [Livewire installation steps](https://livewire.laravel.com/docs/installation).

Once Livewire has been installed, if you haven't already, ensure the [Laravel Database Notifications have been installed](https://laravel.com/docs/10.x/notifications#database-prerequisites) into your app.

```
php artisan notifications:table

php artisan migrate
```

This should create database table used to house your notifications. Next, make sure your User model (or relevant alternative model) has the notifiable trait added as mentioned in the [Laravel Documentation](https://laravel.com/docs/10.x/notifications#using-the-notifiable-trait) and also add the `HasMegaphone` trait provided by Megaphone.

```
