Laravel 4: Elegant Growl-Like Notifications

Here is an extremely simple and elegant way to send Growl-like notifications to your users. It requires the Notifications package for Laravel 4, as well as the Alertify jQuery plugin.

Notifications in Laravel

With the Notification package installed, it’s time to get to work sending notifications to our users. The Notification package makes this dead simple. Here is a couple examples:

Creating notifications in your controller requires one line of code:

Displaying Errors with Alertify

Displaying our alerts is also dead simple. Create a partial view and include it in your master layout, or include the following code directly in your layout:

Wrapup

This is a simplified version, but it will give you some great functionality to build off of. For instance, the Notification package offers a warning notification, which I’ve left out as warning notifications are not implemented in the Alertify plugin. The notification package also allows you to create ‘instant notifications’ which are shown in the same request (i.e. don’t require a redirect), but using these requires using a different method, such as:

I hope you’ve enjoyed this post and if you have a creative way of sending notifications please share it in the comments!

  • Mikey

    Thanks for this! :)

  • Mrclay

    This doesn’t work with me. :(

    • http://www.moderncognition.com crhayes

      What issues are you running into?

  • Pavel

    How they read an notification? AJAX?

  • Bunlong Heng

    It doesn’t work for me as well. I got the text to display, but not the style.