2017 © Pedro Peláez
 

library laravel-alert

Laravel global site message system

image

hieu-le/laravel-alert

Laravel global site message system

  • Thursday, August 24, 2017
  • by letrunghieu
  • Repository
  • 1 Watchers
  • 6 Stars
  • 3,034 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 2 Open issues
  • 12 Versions
  • 6 % Grown

The README.md

Laravel Alert

Build Status Latest Stable Version Code Climate Test Coverage Total Downloads License, (*1)

Global site message system for Laravel 4 (for Laravel 5, see laravel-5 branch), (*2)

The purpose of this package:

  • Generate alerts in many semantic meaning: success, info, warning, error
  • Flash collected messages to the next request
  • Display collected messages to customizabled view, default to Bootstrap 3 alert
  • Support icons for each type of message.

Installation

You will need Composer to use this package. There is a nice tutorial of using Composer for those who are not familiar with this awesome tool., (*3)

Add this to your composer.json file., (*4)

"hieu-le/laravel-alert": "~1.0"

Run composer update to update all dependencies. After that, register the service provider for Laravel by adding this line to the providers array in app/config/app.php, (*5)

'HieuLe\Alert\AlertServiceProvider',

And add this alias to the aliases array in app/config/app.php, (*6)

'Alert' => 'HieuLe\Alert\Facades\Alert',

Usage

To add new message, use one of these four method. The name of each method is the type of the message you want to add., (*7)

Alert::success($message);
# or
Alert::info($message);
# or
Alert::warning($message);
# or
Alert::error($message);

To make these message available in next request, you must call Alert::flash() at least one time., (*8)

Alert::flash()

In your view, use the method Alert::dump to display these messages. By default, each type of message is rendered with the format of Bootstrap 3 alert. You can change they appearance by reading the configuration section below., (*9)

Configuration

You can get more control over this package by modifying these configuations. First of all, publish the package config, so that you can edit the copied version:, (*10)

php artisan config:publish hieu-le/laravel-alert

Open app/config/packages/hieu-le/laravel-alert/config file and change these settings:, (*11)

  • session_key: the name of the session key that stored messages between requests. You normally do not want to edit its value
  • icon: the icon for each type of message when rendered in the default view. You can remove the value of one key to disable the icon for that type of message.
  • view: the name of the view being used to render each type of message. In the view, you can use 2 variables: $icon is the icon of this message type; $messages: an array of messages of the current message type.

Work with Laravel validation errors result

To display the validation error, simply add another parameter to the Alert::dump method. For example, (*12)

// In each view, there is a special variable call $errors
// This is the validation errors that is set by calling "withError" method as
// guided at http://laravel.com/docs/4.2/validation#error-messages-and-views

echo Alert::dump($errors->all()); 

The Versions

24/08 2017

dev-laravel-5

dev-laravel-5

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

24/08 2017

2.2.0

2.2.0.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

23/08 2017

dev-master

9999999-dev

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

13/08 2015

2.1.1

2.1.1.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

11/04 2015

2.1.0

2.1.0.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

11/04 2015

1.1.0

1.1.0.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

11/04 2015

1.0.2

1.0.2.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

11/04 2015

2.0.0

2.0.0.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

11/04 2015

1.0.1

1.0.1.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

09/04 2015

1.0.0

1.0.0.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

09/04 2015

0.0.2

0.0.2.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global

09/04 2015

0.0.1

0.0.1.0

Laravel global site message system

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel bootstrap message alert global