diff --git a/src/Laracasts/Flash/FlashServiceProvider.php b/src/Laracasts/Flash/FlashServiceProvider.php index 7ac3425..726a0d3 100644 --- a/src/Laracasts/Flash/FlashServiceProvider.php +++ b/src/Laracasts/Flash/FlashServiceProvider.php @@ -2,6 +2,7 @@ namespace Laracasts\Flash; +use Illuminate\Http\RedirectResponse; use Illuminate\Support\ServiceProvider; class FlashServiceProvider extends ServiceProvider @@ -28,6 +29,20 @@ public function register() $this->app->singleton('flash', function () { return $this->app->make('Laracasts\Flash\FlashNotifier'); }); + + RedirectResponse::macro('withFlash', function ($message = null, $level = 'info', $important = false) { + $flash = app('flash'); + + if (!is_null($message)) { + $flash->message($message, $level); + + if ($important) { + $flash->important(); + } + } + + return $this; + }); } /**