Coder Social home page Coder Social logo

laravel-notify's Introduction

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.

Android Version

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

🎞️ Video Tutorial

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 8 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();
}

A complete example:

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


        <x-notify::notify />
        @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

License

license. Please see the license file for more information.

laravel-notify's People

Contributors

akunbeben avatar amrography avatar ash-jc-allen avatar codelover254 avatar dependabot[bot] avatar jojo-bear avatar laravel-shift avatar mckenziearts avatar otatechie avatar ramonpego avatar rogermedico avatar ruban-s avatar shailesh-ladumor avatar spaantje avatar temian1 avatar youssef3wi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-notify's Issues

Toast default Title

please you have to make the toast title editable like this:

notify()->success('Message', 'Title');

RTL support

Hi
I use Bootstrsp RTL , 'top-let' position not wok also close button not on the it place
Untitled

Notifcation display timer

Do we have an option to set how long the notification is displayed and also the close button doesn't seem to work

Close button don't work

Close button don't work and icons don't display automatically, it show only when I copied a fonts folder on my public folder

Notification

Can we call it from inside a Notification/notifiable

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.

Ajax / Js Support

Is there any support to trigger the notification via javascript ?

Bad icon

Bad icon for "Drake Notification" (error) 😅
Annotation 2020-05-29 011403

Re-Position notify

This is my first time using Laravel-notify, I would like to change the position of the notification box from top-right to somewhere like button-right. Any ideas?

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?

Demo is not working

The Mix manifest does not exist. (View: /opt/lampp/htdocs/www/AuBoulot.com/vendor/mckenziearts/laravel-notify/resources/views/layout/app.blade.php) (View:

Notification under Bootstrap4 NavBar

Maybe it is just for me, but whatever I use, the notification it is always show up under the NavBar (top-right, top-left, center-top).

If I modify the CSS like this, it solve this:
.notify-alert { ... top: auto; ... }
.connectify-alert { ... top: auto; ... }

Custom alert boxes

Hi i would like to know if we can design our own custom notify alert boxes and add them to the notify service.
Not preset-messages

I'm getting an error while installing

Hi, i use laravel 8.

I just tried to install it with composer. But i take an error.

`Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove laravel/framework v8.1.0
- Conclusion: don't install laravel/framework v8.1.0
- mckenziearts/laravel-notify 2.x-dev requires illuminate/support ~7.0 -> satisfiable by illuminate/support[7.x-dev, v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0
, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.21.0, v7.22.0, v7.22.1, v7.22.2, v7.22.3,
v7.22.4, v7.23.0, v7.23.1, v7.23.2, v7.24.0, v7.25.0, v7.26.0, v7.26.1, v7.27.0, v7.28.0, v7.28.1, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
- mckenziearts/laravel-notify v2.0 requires illuminate/support ~7.0 -> satisfiable by illuminate/support[7.x-dev, v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v
7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.21.0, v7.22.0, v7.22.1, v7.22.2, v7.22.3, v7
.22.4, v7.23.0, v7.23.1, v7.23.2, v7.24.0, v7.25.0, v7.26.0, v7.26.1, v7.27.0, v7.28.0, v7.28.1, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
- don't install illuminate/support 7.x-dev|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.3|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.4|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.5|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.6|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.7|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.0.8|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.1.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.1.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.1.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.1.3|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.10.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.10.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.10.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.10.3|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.11.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.12.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.13.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.14.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.14.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.15.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.16.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.16.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.17.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.17.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.17.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.18.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.19.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.19.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.2.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.2.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.2.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.20.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.21.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.22.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.22.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.22.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.22.3|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.22.4|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.23.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.23.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.23.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.24.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.25.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.26.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.26.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.27.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.28.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.28.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.3.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.4.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.5.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.5.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.5.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.6.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.6.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.6.2|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.7.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.7.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.8.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.8.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.9.0|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.9.1|don't install laravel/framework v8.1.0
- don't install illuminate/support v7.9.2|don't install laravel/framework v8.1.0
- Installation request for laravel/framework (locked at v8.1.0, required as ^8.0) -> satisfiable by laravel/framework[v8.1.0].
- Installation request for mckenziearts/laravel-notify ^2.0 -> satisfiable by mckenziearts/laravel-notify[2.x-dev, v2.0].

Installation failed, reverting ./composer.json to its original content.
`

How can i solve this error? Thanks.

Close button not working

Hi, hope you're fine.

This error appear when I try to close notify() or connectify() :
Uncaught DOMException: Failed to execute 'remove' on 'DOMTokenList': The token provided must not be empty. at http://www.something.local/vendor/mckenziearts/laravel-notify/js/notify.js:1:1901

Thanks for your help !

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?

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>)

Question about self-closing

hi ,
thank you for this awesome package,
please i wanted to know if there is a timer to add to have the self-closing of the alert ...

THANK YOU!

I have an issue... The package is so beautifully designed that I want to cry!!!

Thank you kindly for making it, @mckenziearts!^_^

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.

Publishing not complete.

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

sessions message is not destroying itself after displaying onces.

sessions message is not destroying itself after displaying onces. if we click the back icon button on browser it will show the same message againg.

public function store()

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

return Redirect::route();

}
Big problem
this success message is shown again if we back the browser with browser back icon. Success message is not destroying itself after
displaying once.
it's sessions should be deleted after displaying success message and it is not deleting the session after displaying onces.

When I install notify on Laravel 8, layout.app not is found

After Laravel 8 installed e laravel-notify installed too, I run artisan serve and access "notify/demo" route. At this time I see that error:

View [layout.app] not found. (View: /home/usuario/Projetos/Evaldo/Estudos/pr-l-notify/vendor/mckenziearts/laravel-notify/resources/views/notify.blade.php)

I think it is a call to a view that is extending a laravel-notify template instead of "layouts/app" default laravel template.

I will do a PR to fix it.

Hardcoded success-warning-...

Could you please implement that the messages like this
<i class="flaticon-like"></i><span>{{ session()->get('notify.type') }}</span>
cannot be hardcoded, but read from the session like the title
<h4>{{ session()->get('notify.title') }}</h4> ?

Thanks!

Responsive (viewport)

The Notification isn´t responsive in mobile view due to the meta name="viewport" content="width=device-width, initial-scale=1.0"
Sem Título

custom rules error regex validator

-> hi
-> i tried use as regex custom validator

public function rules()
{
return [
'name' => 'required|string|min:3',
'email' => 'required|email',
];
}

public function messages()
{
$messages = [
'name.required' => notify()->error('Name must be filled.'),
'name.min' => notify()->error('Name must be at least 3 characters.'),
'name.regex' => notify()->error('Name must use Alphabet and space.'),
];

    return $messages;
}

-> but get me

Object of class Mckenziearts\Notify\LaravelNotify could not be converted to string
-> help

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.

Notification displayed twice

The notification window is displayed twice (during the load of the page and then when the page is fully loaded)
Do you have any idea how to prevent that?

in_class delay

Hello,

could you please add a variable to 'animate' config to manage the in_class delay before the animation start?

Thank you!

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

Doesn't work with the Laravel 8 and Livewire

Hi,

When I use a Livewire component in the view, it doesn't work. When I remove a Livewire component, a notification appears on the website.

<!doctype html>
<html lang="en">
<head>
    <!-- Scripts -->
    <script src="{{ mix('js/app.js') }}" defer></script>

    <!-- Styles -->
    <link href="{{ mix('css/app.css') }}" rel="stylesheet">

    @livewireStyles
    @notifyCss
</head>
<body>
    <div>
        @yield('content')
    </div>

    @include('notify::messages')

    @livewireScripts
    @notifyJs
    @stack('scripts')
</body>
</html>
@extends('layouts.app')

@livewire('season.show')
@livewire('counter')

Higher z-index value in css

I think you should add higher z-index value, for the container, sometimes the message show at the back of navbar that has higher z-index value

Unable to locate publishable resources.

solve with php artisan vendor:publish --provider="Mckenziearts\Notify\LaravelNotifyServiceProvider"
used double quotes not :php artisan vendor:publish --provider='Mckenziearts\Notify\LaravelNotifyServiceProvider'

notify.js not working

Hello, when integrating notify on a laravel and VueJS project, the notify.js file could not be inserted. Here is the error I have in my console.

SharedScreenshot
have Possible solutions?

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.