| Package Data | |
|---|---|
| Maintainer Username: | kohkimakimoto |
| Maintainer Contact: | kohki.makimoto@gmail.com (Kohki Makimoto) |
| Package Create Date: | 2014-08-13 |
| Package Last Update: | 2014-08-17 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-25 03:00:11 |
| Package Statistics | |
|---|---|
| Total Downloads: | 37 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 1 |
| Total Watchers: | 1 |
| Total Forks: | 1 |
| Total Open Issues: | 0 |
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
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',
),
The MIT License
Kohki Makimoto kohki.makimoto@gmail.com