kohkimakimoto/laravel-message-binder
| Install | |
|---|---|
composer require kohkimakimoto/laravel-message-binder |
|
| Latest Version: | v0.1.1 |
| PHP: | >=5.4.0 |
| Laravel: | 4 |
| License: | MIT |
| Last Updated: | Aug 17, 2014 |
| Links: | GitHub · Packagist |
Laravel Message Binder
A little hack for Illuminate View to access flash messages easily.
You can use the withMessages method like a laravel builtin method withErrors in a general purpose.
Route::get('register', function()
{
return View::make('user.register');
});
Route::post('register', function()
{
$rules = array(...);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
return Redirect::to('register')->withErrors($validator);
}
// You can use the `withMessages` method like a laravel builtin method `withErrors` in a general purpose.
return Redirect::to('register')->withMessages(array('default' => 'Success!');
});
After redirection, you may utilize the automatically bound $messages variable in your view:
<?php echo $messages->first('default'); ?>
see also laravel docs#validation
Installation
Add dependency in composer.json
"require": {
"kohkimakimoto/laravel-message-binder": "0.*"
}
Run composer update command.
$ composer update
Add MessageBinderServiceProvider to providers array in app/config/app.php
'providers' => array(
...
'Kohkimakimoto\MessageBinder\MessageBinderServiceProvider',
),
LICENSE
The MIT License
Author
Kohki Makimoto kohki.makimoto@gmail.com
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.1.1 | >=5.4.0 | 4.* | MIT | |
| v0.1.0 | >=5.4.0 | 4.* | MIT |