Flexible Flash notifications for Laravel

Last update: May 23, 2022

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Notify is a package that lets you add custom notifications to your project. A diverse range of notification design is available.

Version Guidance

Version Laravel version Status Branch Install
1.x 5.5, 5.6, 5.7, 6.0 EOL 1.0 composer require mckenziearts/laravel-notify 1.*
2.x >= 7.0 Latest 2.0 composer require mckenziearts/laravel-notify

Android Version

If you need Android version please try this package Aesthetic Dialogs. Happy Coding 👨🏾‍💻

Installation

You can install the package using composer

$ composer require mckenziearts/laravel-notify

Then add the service provider to config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

'providers' => [
    ...
    Mckenziearts\Notify\LaravelNotifyServiceProvider::class
    ...
];

You can publish the configuration file and assets by running:

$ php artisan vendor:publish --provider="Mckenziearts\Notify\LaravelNotifyServiceProvider"

Now that we have published a few new files to our application we need to reload them with the following command:

$ composer dump-autoload

Usage

  1. Add styles links with @notifyCss
  2. Add scripts links with @notifyJs
  3. use notify() helper function inside your controller to set a toast notification for info, success, warning or error
  4. Include notify partial to your master layout @include('notify::components.notify')

If you are on Laravel 7 or greater, you can use the tag syntax.

<x:notify-messages />

Basic

Within your controllers, before you perform a redirect call the notify method with a message.

public function store()
{
    notify()->success('Laravel Notify is awesome!');

    return Redirect::home();
}

An complete example:

<!doctype html>
<html>
    <head>
        <title>Laravel Notify</title>
        @notifyCss
    </head>
    <body>


        @include('notify::messages')
        // Laravel 7 or greater
        <x:notify-messages />
        @notifyJs
    </body>
</html>

Type of notifications

Laravel Notify actually display 5 types of notifications

  1. toast notification, (The default notification for Laravel Notify)
notify()->success('Welcome to Laravel Notify ⚡️') or notify()->success('Welcome to Laravel Notify ⚡️', 'My custom title')
  1. connectify notification, example of basic usage
connectify('success', 'Connection Found', 'Success Message Here')
  1. drakify ( 😎 ) notification, displays an alert only
drakify('success') // for success alert
or
drakify('error') // for error alert
  1. smilify notification, displays a simple custom toast notification using the smiley ( 😊 ) emoticon
smilify('success', 'You are successfully reconnected')
  1. emotify notification, displays a simple custom toast notification using a vector emoticon
emotify('success', 'You are awesome, your data was successfully created')

Preset Notifications

If you have a specific notification that is used across multiple different places in your system, you can define it as a preset notification in your config file. This makes it easier to maintain commonly used notifications in one place. Read how to define preset messages in the Config section below.

As an example, to use a preset notification you have defined called 'common-notification', use the following:

notify()->preset('common-notification')

You can override any of the values that are set in the config if you need to. For example, this could be useful if you have a common notification across, but you want to change the icon in one particular place that it's used without having to manually write out a new notification.

To do this, simply pass in an array that has the key of the attribute that you want to override and the value you want to override it with.

As an example, we could override the 'title' of our 'common-notification' by using the following:

notify()->preset('common-notification', ['title' => 'This is the overridden title'])

Config

Config file are located at config/notify.php after publishing provider element.

Some awesome stuff. To active dark mode update the theme config, or add global variable NOTIFY_THEME on your .env file

'theme' => env('NOTIFY_THEME', 'dark'),

You can define preset notifications in the config file using the following structure:

'preset-messages' => [
    'user-updated' => [
        'message' => 'The user has been updated successfully.',
        'type'    => 'success',
        'model'   => 'connect',
        'title'   => 'User Updated',
    ],
    'user-deleted' => [
        'message' => 'The user has been deleted successfully.',
        'type'    => 'success',
        'model'   => 'connect',
        'title'   => 'User Deleted',
    ],
],

The example above shows the config for two preset notifications: 'user-updated' and 'user-deleted'.

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

Donate ❤️

If you use and enjoy Laravel Notify you can encourage the author by

Donors list:

  1. Charlie J - (10,00 $ USD) - Donation made with love by Charlie from United Kingdom - 9 October 2020

License

license. Please see the license file for more information.

GitHub

https://github.com/mckenziearts/laravel-notify
Comments
  • 1. Does not auto-close

    Hi,

    I'm not sure what is causing this. I'm using Laravel 8, fresh install.

    Got this in my template:

    <head>
    ....
    @notifyCss
    </head>
    <body>
    @include('notify::messages')
    @notifyJs
    </body>
    
    • The notification appear as it should.
    • Does not auto-close.

    Also tried to change the location to the bottom-right, but it still show in upper right corner:

    'position' => 'bottom-right',
    

    Not sure what is causing this.

    Reviewed by kgp43 at 2020-12-28 16:13
  • 2. Css not Found

    GET http://127.0.0.1:8000/vendor/mckenziearts/laravel-notify/css/notify.css net::ERR_ABORTED 404 (Not Found) login:8 GET http://127.0.0.1:8000/vendor/mckenziearts/laravel-notify/js/notify.js net::ERR_ABORTED 404 (Not Found)

    Reviewed by sharmaanil8866 at 2019-11-15 06:08
  • 3. Problem integrating this into a livewire controller

    i try to integrate this into a livewire controller but dont get any resonse withing the function.

    I call it like:

    public function render() { notify()->success('Title was successfully rated.', 'Rating sucessfull'); return view('livewire.infobarrating'); }

    but no notification is rendered on the blade.

    what am i doing wrong?

    Reviewed by KangarooMusiQue at 2020-05-26 09:42
  • 4. position config setting not working

    i set my notify.php config to have 'position' => 'bottom-right', but the notify still comes up in the top right, no matter where i set position to it always shows up in the top right corner of the browser.

    Reviewed by Chrisx84 at 2020-01-20 22:38
  • 5. Unable to close the flash notification

    First of all, congratulations guys for your work. When I integrate laravel-notify in my project, I can't close the fash notitication. Do you know why?

    Reviewed by gausoft at 2019-11-14 22:43
  • 6. [2.2] Urgent !. message.blade.php missing.

    hi.

    I just finished upgrading laravel version with composer.

    One of my project is using laravel-notify.

    It got error after upgrading to laravel 8.45.1.

    Following file was missing.

    'vendor/mckenziearts/laravel-notify/resources/views/messages.blade.php'

    please fix it.

    Reviewed by magic-thomas at 2021-06-06 20:41
  • 7. Close button not working..

    I am getting the following error while closing the notification. Please guide me about it.

    app.js:38298 [Vue warn]: Property or method "show" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
    
    (found in <Root>)
    
    Reviewed by MHassanSaqib at 2020-08-29 19:49
  • 8. It's does not support in java script code

    • It's does not support in java script code
    • if i want specially in jquery or javascript code like toastr your notify message does not worked .
    • for e.g toastr.success("User has been created successfully!") this work in jquery and javascript but notify.success("Message") this is not worked . How we can use in jquery or javascript ?
    Reviewed by gautampatel5317 at 2021-04-15 14:13
  • 9. Notify fired twice

    Hi,

    I'm using laravel 8 notify works very good, the only thing is that it fire one time very fast and diapered and after it comes "it suppose" the good one and sty there.

    Can you help me ?

    I put @notifyCss in my head / @notifyJs in my footer and <x:notify-messages /> in my blade page.

    Reviewed by Spillo17 at 2020-12-30 19:58
  • 10. Publishing not complete.

    Enter the command php artisan vendor:publish --provider='Mckenziearts\Notify\LaravelNotifyServiceProvider' than error Unable to locate publishable resources. Screenshot_1

    Reviewed by thakor-maheshkumar at 2020-01-12 08:28
  • 11. ⬆️ Bump nanoid from 3.1.23 to 3.3.2

    Bumps nanoid from 3.1.23 to 3.3.2.

    Changelog

    Sourced from nanoid's changelog.

    3.3.2

    • Fixed enhanced-resolve support.

    3.3.1

    • Reduced package size.

    3.3

    • Added size argument to function from customAlphabet (by Stefan Sundin).

    3.2

    • Added --size and --alphabet arguments to binary (by Vitaly Baev).

    3.1.32

    • Reduced async exports size (by Artyom Arutyunyan).
    • Moved from Jest to uvu (by Vitaly Baev).

    3.1.31

    • Fixed collision vulnerability on object in size (by Artyom Arutyunyan).

    3.1.30

    • Reduced size for project with brotli compression (by Anton Khlynovskiy).

    3.1.29

    • Reduced npm package size.

    3.1.28

    • Reduced npm package size.

    3.1.27

    • Cleaned dependencies from development tools.

    3.1.26

    • Improved performance (by Eitan Har-Shoshanim).
    • Reduced npm package size.

    3.1.25

    • Fixed browserify support.

    3.1.24

    • Fixed browserify support (by Artur Paikin).
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Reviewed by dependabot[bot] at 2022-03-30 02:14
  • 12. using put and pull instead of flash and get to ensure the message getting shown

    Rewritten the use of flash and get to use put and pull. This way the system ensures the message have been displayed in case the site uses multiple calls/loads. It also provides a wider support/range for those who have difficulties and issue with their sessions due to the multiple loads of their page.

    Reviewed by JoJo-Bear at 2022-05-10 10:00
  • 13. ⬆️ Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Reviewed by dependabot[bot] at 2022-03-30 02:24
  • 14. Laravel 9.0.2 installation error

    I'm trying to install Notify v2 on Laravel 9.0.2 but I'm getting the following error: Your requirements could not be resolved to an installable set of packages. Problem 1 - mckenziearts/laravel-notify[v1.0, ..., 1.x-dev] require illuminate/support ~5.0|~6.0|~7.0 -> found illuminate/support[v5.0.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require. - Root composer.json requires mckenziearts/laravel-notify 1.* -> satisfiable by mckenziearts/laravel-notify[v1.0, ..., 1.x-dev].

    I already ran composer update, composer install and both composer require mckenziearts/laravel-notify and composer require mckenziearts/laravel-notify 1.* but no success

    Reviewed by martijnschuman at 2022-03-05 11:37
  • 15. Destroying my Style and Js

    when i insert @notifyCss and @notifyJs, it will destroy my Style and Java Script, make my website not work at all.

    please fix.

    i am using tailwind 3.0 and alpine js

    Reviewed by hrace009 at 2022-02-18 16:00
Laravel package to launch toast notifications.
Laravel package to launch toast notifications.

Laravel package to launch toast notifications. This package provides assistance when using toast notifications. Using the iziTOAST package, which allo

Mar 14, 2022
Laravel Subscribable Notifications

Laravel Subscribable Notifications This package allows you to subscribe your app Users to your app Notifications and dispatch them without specifying

Mar 18, 2022
Larafirebase is a package thats offers you to send push notifications or custom messages via Firebase in Laravel.
Larafirebase is a package thats offers you to send push notifications or custom messages via Firebase in Laravel.

Introduction Larafirebase is a package thats offers you to send push notifications or custom messages via Firebase in Laravel. Firebase Cloud Messagin

May 6, 2022
A package to simplify automating future notifications and reminders in Laravel
A package to simplify automating future notifications and reminders in Laravel

Laravel Snooze Schedule future notifications and reminders in Laravel Why use this package? Ever wanted to schedule a future notification to go out at

May 11, 2022
📨 Facebook Notifications Channel for Laravel
📨 Facebook Notifications Channel for Laravel

Facebook Notifications Channel for Laravel This package makes it easy to send notifications using the Facebook Messenger with Laravel. Contents Instal

Apr 13, 2022
Push Notifications using Laravel
Push Notifications using Laravel

laravel-push-notification Push Notifications using Laravel PushNotification::send(['deviceToken1', 'deviceToken2',..], 'Notification Message', 'Action

Apr 6, 2022
Laravel package to enable sending push notifications to devices

Laravel Push Notification Package to enable sending push notifications to devices Installation Update your composer.json file to include this package

Apr 25, 2022
✈️ Whatsapp Notifications Channel for Laravel

Whatsapp Notifications Channel for Laravel This package makes it easy to send Whatsapp notification using Venom API with Laravel. This package was cre

Apr 27, 2022
Send Firebase push notifications with Laravel php framework.

FCM Notification Channel for Laravel Send Firebase push notifications with Laravel php framework. Installation You can install this package via compos

May 21, 2022
Standalone PHP library for easy devices notifications push.

NotificationPusher Standalone PHP library for easy devices message notifications push. Feel free to contribute! Thanks. Contributors Cédric Dugat (Aut

May 9, 2022
:computer: Send notifications to your desktop directly from your PHP script
:computer: Send notifications to your desktop directly from your PHP script

About JoliNotif JoliNotif is a cross-platform PHP library to display desktop notifications. It works on Linux, Windows or MacOS. Requires PHP >= 7.2 (

May 12, 2022
A very lightweight library to handle notifications the smart way.
A very lightweight library to handle notifications the smart way.

NAMSHI | Notificator Notificator is a very simple and lightweight library to handle notifications the smart way. It took inspiration from other librar

May 9, 2022
Takes care of Apple push notifications (APNS) in your PHP projects.

Notificato Notificato takes care of push notifications in your PHP projects. Italian: notificato è: participio passato English: notified Why use Notif

Apr 17, 2022
A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.

php-pushwoosh A PHP Library to easily send push notifications with the Pushwoosh REST Web Services. First sample, creating a Pushwoosh message // Crea

Jan 27, 2022
Notifications in PHP (notify-send, growl, etc) like that.

#Nod Notifications in PHP (notify-send, growl, etc) like that. ##Examples Letting Nod figure out the best Adapter to use (not recommend ATM, only work

Mar 26, 2019
Sends notifications via one or more channels (email, SMS, ...).

Notifier Component The Notifier component sends notifications via one or more channels (email, SMS, ...). Resources Documentation Contributing Report

May 21, 2022
Send push notifications to apple devices (iPhone, iPad, iPod).

Apple Apn Push Send push notifications to apple devices (iPhone, iPad, iPod). Support authenticators: Certificate Json Web Token Supported protocols:

Apr 26, 2022
This package allows you to send notifications to Microsoft Teams.
This package allows you to send notifications to Microsoft Teams.

Teams connector This package allows you to send notifications to Microsoft Teams. Installation You can install the package using the Composer package

May 6, 2022
Push notifications Library for PHP

Push notifications Library for PHP Supported Protocols Protocol Supported Driver Options APNs (Token Based) ✓ APNs\Token APNs\Token\Option APNs (Certi

Mar 25, 2022