michaeljennings / errormanager by michaeljennings

A laravel 4 error manager package
12
0
1
Package Data
Maintainer Username: michaeljennings
Maintainer Contact: michael.jennings91@gmail.com (Michael Jennings)
Package Create Date: 2014-12-25
Package Last Update: 2015-03-30
Language: PHP
License: Unknown
Last Refreshed: 2024-05-03 15:02:18
Package Statistics
Total Downloads: 12
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Error Manager

A wrapper for the laravel 4 message bag to make it simpler to add and retrieve messages, also flashes messages to the session so they can be retrieved on the next request.

Installation

Include the package in your composer.json.

"michaeljennings/errormanager": "dev-master";

Run composer install or composer update to download the dependencies.

Once the package has been downloaded add the validation service provider to the list of service providers in app/config/app.php.

'providers' => array(

'Michaeljennings\ErrorManager\ErrorManagerServiceProvider'

);

Add the Error facade to your aliases array.

'aliases' => array(
  
  'Error' => 'Michaeljennings\ErrorManager\Facades\Error',

);

Usage

To add a message into the message bag use the add method.

Error::add('foo', 'bar');

To check if there are any errors in the current message bag use the hasErrors method.

Error::hasErrors();

To retrieve the errors from the message bag use the errors method.

Errors::errors();

You may also use any of the standard message bag functions.

$errors = Errors::errors();

$errors->has('foo)
$errors->first('bar')

You may also redirect with the errors.

return Redirect::back()->withErrors(Errors::errors());