Flexible Flash notifications for Laravel

Overview

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.

Comments
  • Does not auto-close

    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.

    enhancement 
    opened by kgp43 11
  • Css not Found

    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)

    opened by sharmaanil8866 9
  • Problem integrating this into a livewire controller

    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?

    enhancement 
    opened by KangarooMusiQue 7
  • position config setting not working

    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.

    opened by Chrisx84 6
  • Unable to close the flash notification

    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?

    opened by gausoft 5
  • [2.2] Urgent !. message.blade.php missing.

    [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.

    opened by magic-thomas 3
  • It's does not support in java script code

    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 ?
    opened by gautampatel5317 3
  • Close button not working..

    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>)
    
    opened by MHassanSaqib 3
  • Notify fired twice

    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.

    opened by Spillo17 2
  • Publishing not complete.

    Publishing not complete.

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

    opened by thakor-maheshkumar 2
  • ⬆️ Bump nanoid from 3.1.23 to 3.3.2

    ⬆️ 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.

    dependencies 
    opened by dependabot[bot] 1
  • How to show validation error?

    How to show validation error?

    I put validation in my controller but when any validation fails then it is not showing any message.

    $request->validate([ 'name' => 'required', ]);

    opened by BilawalSh 2
  • use margin start instead of margin left

    use margin start instead of margin left

    I use RTL language and the layout wan't very good. I fixed it by replacing ml-* (margin left) with ms-* (margin start).

    please fix it in next release, Thank you.

    opened by malozaibi 0
  •  line 98 of readme.md maybe @include('notify::components.notify')

    line 98 of readme.md maybe @include('notify::components.notify')

    https://github.com/mckenziearts/laravel-notify/blob/a75449fcc1a3e50ac8d1d41a026142461017b4ca/readme.md?plain=1#L98

    I refer to line 98 of readme.md write it in the layout view file @include('notify::messages'), then I got the following error

    InvalidArgumentException
    View [messages] not found. (View: /mnt/s/WorkSpaces/HeyCommunity/HeyCommunity-backend/resources/views/dashboard/layouts/default.blade.php)
    

    Meybe line 98 should be the same as line 65?

    https://github.com/mckenziearts/laravel-notify/blob/a75449fcc1a3e50ac8d1d41a026142461017b4ca/readme.md?plain=1#L65

    opened by supgeek-rod 0
  • Add Alpine.js animations or ability to customize with Tailwind CSS

    Add Alpine.js animations or ability to customize with Tailwind CSS

    It would be nice to have ability to add animation when it slides in or out or the ability to customize the design with Tailwind CSS. Maybe a vendor:publish type thing.

    opened by safeboot 0
  • Notify Package Icons

    Notify Package Icons

    Hello,

    Is there any way to add a feature in config files to use icons from other vendors such as fontawsome or bootstrap icons to update the notification icon without updating vendor files?

    <span class="flex-shrink-0 h-10 w-10 flex items-center justify-center bg-white rounded-full">
        <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" class="check w-6 h-6 text-green-600">
             <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7">
             </path>
       </svg>
    </span>
    
    opened by ayaseensd 0
Releases(v2.3)
  • v2.3(Apr 2, 2022)

    What's Changed

    • 2.x by @mckenziearts in https://github.com/mckenziearts/laravel-notify/pull/58
    • :art: Correct notification messages view name by @amrography in https://github.com/mckenziearts/laravel-notify/pull/70
    • Add Support for Laravel 9.x by @spaantje in https://github.com/mckenziearts/laravel-notify/pull/83

    New Contributors

    • @mckenziearts made their first contribution in https://github.com/mckenziearts/laravel-notify/pull/58
    • @amrography made their first contribution in https://github.com/mckenziearts/laravel-notify/pull/70
    • @spaantje made their first contribution in https://github.com/mckenziearts/laravel-notify/pull/83

    Full Changelog: https://github.com/mckenziearts/laravel-notify/compare/v2.2...v2.3

    Source code(tar.gz)
    Source code(zip)
  • v2.2(May 29, 2021)

  • v2.1(Sep 16, 2020)

  • v2.0(Aug 24, 2020)

    Version 2 is Here 🤩 ! Laravel Notify is a package that lets you add custom notifications to your project. A diverse range of notification design with TailwindCSS and TailwindUI.

    Added

    • TailwindCSS & UI
    • AlpineJS
    • Notify component for Laravel 7

    If you are using Laravel 7 you can now add this on your master blade

     <x:notify-messages />
    

    Updated

    • Config file, remove all animation stuff
    • All notify styles, all built with Tailwindcss
    • Demo preview UI
    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Feb 22, 2020)

  • v1.1.1(Dec 17, 2019)

  • v1.1(Dec 12, 2019)

  • v1.0.6(Nov 28, 2019)

  • v1.0.5(Nov 22, 2019)

    Added

    • notification position configuration in config/notify.php to set where notification should display.

    Updated

    • notify style and javascript
    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Nov 14, 2019)

  • v1.0.3(Nov 11, 2019)

  • v1.0.2(Nov 10, 2019)

  • v1.0.1(Nov 7, 2019)

  • v1.0(Nov 5, 2019)

Owner
Arthur Monney
Fullstack Designer - Laravel & React Developer. Laravel Cameroon Organizer @laravelcm | @shopperlabs 🛍
Arthur Monney
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

Anthony Medina 7 Nov 25, 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

Andrés Santibáñez 132 Nov 10, 2022
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

Kutia Software Company 264 Jan 7, 2023
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

Thomas Kane 720 Jan 7, 2023
📨 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

Laravel Notification Channels 142 Dec 27, 2022
Push Notifications using Laravel

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

Webelight Solutions 26 Jul 22, 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

Davi Nunes 1.2k Sep 27, 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

Felipe Damaceno Teodoro 63 Dec 7, 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

Ankur Kumar 23 Oct 31, 2022
This package makes it easy to send notifications using RocketChat with Laravel 9.0+.

laravel-rocket-chat-notifications Introduction This package makes it easy to send notifications using RocketChat with Laravel 9.0+. Contents Installat

Team Nifty GmbH 25 Dec 1, 2022
This package makes it easy to send web push notifications with Laravel.

Web push notifications channel for Laravel This package makes it easy to send web push notifications with Laravel. Installation You can install the pa

Laravel Notification Channels 564 Jan 3, 2023
Notion.so notifications channel for Laravel

Installation composer require astroshippers/notion-notification-channel Usage Inside eloquent model: public function routeNotificationForNotion(): arr

AstroShippers 3 Jul 4, 2022
Event subscriber for Laravel notifications.

Laravel Notification Event Subscriber This package allows you to run any kind of actions while a notification is being sent or after it has been sent

Turan Karatuğ 76 Dec 30, 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

Cédric Dugat 1.2k Jan 3, 2023
: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 (

JoliCode 1.2k Dec 29, 2022
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

Namshi 187 Nov 4, 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

Mathijs Kadijk 223 Sep 28, 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

gomoob 63 Sep 28, 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

Filipe Dobreira 51 Mar 26, 2019