2017 © Pedro Peláez
 

library notification

Package for Laravel for helping to manage flash / instant notifications / messages.

image

edvinaskrucas/notification

Package for Laravel for helping to manage flash / instant notifications / messages.

  • Monday, March 27, 2017
  • by edvinaskrucas
  • Repository
  • 32 Watchers
  • 523 Stars
  • 199,512 Installations
  • PHP
  • 24 Dependents
  • 0 Suggesters
  • 83 Forks
  • 7 Open issues
  • 22 Versions
  • 5 % Grown

The README.md

Package is looking for maintainers Please contact me if interested., (*1)

Notification package for Laravel4 / Laravel5

Build Status, (*2)


A simple notification management package for Laravel4., (*3)


  • Notification containers
  • Notification collections
  • Notification messages
  • Formats for notifications
  • Flash / instant notifications
  • Method chaining
  • Message positioning

Installation

Just place require new package for your laravel installation via composer.json, (*4)

"edvinaskrucas/notification": "5.*"

Then hit composer update, (*5)

Version matrix

Laravel Version Package version
= 5.4 5.2.*
>= 5.1 5.1.*
>= 5.0, < 5.1 5.0.*
>= 4, < 5 >= 2, <= 3

Registering to use it with laravel

Add following lines to app/config/app.php, (*6)

ServiceProvider array, (*7)

\Krucas\Notification\NotificationServiceProvider::class,

Kernel middleware array (must be placed after 'Illuminate\Session\Middleware\StartSession' middleware), (*8)

\Krucas\Notification\Middleware\NotificationMiddleware::class,

Now you are able to use it with Laravel4., (*9)

Publishing config file

If you want to edit default config file, just publish it to your app folder., (*10)

php artisan vendor:publish --provider="\Krucas\Notification\NotificationServiceProvider" --tag="config"

Usage

Default usage

Adding message to default container., (*11)

\Krucas\Notification\Facades\Notification::success('Success message');
\Krucas\Notification\Facades\Notification::error('Error message');
\Krucas\Notification\Facades\Notification::info('Info message');
\Krucas\Notification\Facades\Notification::warning('Warning message');

Containers

Containers allows you to set up different containers for different placeholders., (*12)

You can pass closure to modify containers, simply use this syntax showed below, (*13)

\Krucas\Notification\Facades\Notification::container('myContainer', function($container)
{
    $container->info('Test info message');
    $container->error('Error');
});

Also you can access container like this, (*14)

\Krucas\Notification\Facades\Notification::container('myContainer')->info('Info message');

Method chaining, (*15)

\Krucas\Notification\Facades\Notification::container('myContainer')->info('Info message')->error('Error message');

If you want to use default container just use null as container name. Name will be taken from config file., (*16)

\Krucas\Notification\Facades\Notification::container()->info('Info message');

Instant notifications (shown in same request)

Library supports not only flash messages, if you want to show notifications in same request just use, (*17)

\Krucas\Notification\Facades\Notification::successInstant('Instant success message');

Custom single message format

Want a custom format for single message? No problem, (*18)

\Krucas\Notification\Facades\Notification::success('Success message', 'Custom format :message');

Also you can still pass second param (format), to format messages, but you can format individual messages as shown above., (*19)

Add message as object

You can add messages as objects, (*20)

\Krucas\Notification\Facades\Notification::success(
    \Krucas\Notification\Facades\Notification::message('Sample text')
);

When adding message as object you can add additional params to message, (*21)

\Krucas\Notification\Facades\Notification::success(
    \Krucas\Notification\Facades\Notification::message('Sample text')->format(':message')
);

Add message as closure

You can add messages by using a closure, (*22)

\Krucas\Notification\Facades\Notification::success(function (Message $message) {
    $message->setMessage('Sample text')->setPosition(1);
});

Accessing first notification from container

You can access and show just first notification in container, (*23)

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->get('success')->first() !!}

Accessing first notification from all types, (*24)

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->all()->first() !!}

Displaying notifications

To display all notifications in a default container you need to add just one line to your view file, (*25)

{!! \Krucas\Notification\Facades\Notification::showAll() !!}

When using showAll() you may want to group your messages by type, it can be done like this, (*26)

{!! \Krucas\Notification\Facades\Notification::group('info', 'success', 'error', 'warning')->showAll() !!}

This will group all your messages in group and output it, also you can use just one, two or three groups., (*27)

Manipulating group output on the fly, (*28)

\Krucas\Notification\Facades\Notification::addToGrouping('success')->removeFromGrouping('error');

Display notifications by type in default container, you can pass custom format, (*29)

{!! \Krucas\Notification\Facades\Notification::showError() !!}
{!! \Krucas\Notification\Facades\Notification::showInfo() !!}
{!! \Krucas\Notification\Facades\Notification::showWarning() !!}
{!! \Krucas\Notification\Facades\Notification::showSuccess(':message') !!}

Displaying notifications in a specific container with custom format., (*30)

{!! \Krucas\Notification\Facades\Notification::container('myContainer')->showInfo(':message') !!}

Or you can just use blade extension, (*31)

@notification() // will render default container

@notification('custom') // will render 'custom' container

Message positioning

There is ability to add message to certain position., (*32)

// This will add message at 5th position
\Krucas\Notification\Facades\Notification::info(Notification::message('info')->position(5));
\Krucas\Notification\Facades\Notification::info(Notification::message('info2')->position(1);

Clearing messages

You can clear all messages or by type., (*33)

\Krucas\Notification\Facades\Notification::clearError();
\Krucas\Notification\Facades\Notification::clearWarning();
\Krucas\Notification\Facades\Notification::clearSuccess();
\Krucas\Notification\Facades\Notification::clearInfo();
\Krucas\Notification\Facades\Notification::clearAll();

Add message and display it instantly in a view file

Want to add message in a view file and display it? Its very simple:, (*34)

{!! \Krucas\Notification\Facades\Notification::container('myInstant')
        ->infoInstant('Instant message added in a view and displayed!') !!}

You can also add multiple messages, (*35)

{!! \Krucas\Notification\Facades\Notification::container('myInstant')
        ->infoInstant('Instant message added in a view and displayed!')
        ->errorInstant('Error...') !!}

The Versions

27/03 2017

dev-master

9999999-dev

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

27/03 2017

5.2.0

5.2.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

19/01 2016

5.1.1

5.1.1.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

19/01 2016

dev-dev

dev-dev

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

18/10 2015

5.1.0

5.1.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

18/10 2015

dev-feature/refactor

dev-feature/refactor

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

23/02 2015

5.0.0

5.0.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

23/02 2015

dev-features/laravel-5

dev-features/laravel-5

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

29/09 2014

4.0.0

4.0.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

07/08 2014

3.0.1

3.0.1.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

29/07 2014

3.0.0

3.0.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

15/06 2014

2.0.2

2.0.2.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

30/12 2013

2.0.1

2.0.1.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

29/12 2013

2.0.0

2.0.0.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

07/12 2013

1.2.3

1.2.3.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

06/11 2013

1.2.2

1.2.2.0

Package for Laravel for helping to manage flash / instant notifications / messages.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel messages notifications flash instant

01/10 2013

1.2.1

1.2.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

10/04 2013

1.2

1.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

09/04 2013

1.1.1

1.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

07/04 2013

1.1

1.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

02/04 2013

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

30/03 2013

1.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas