Reputation: 269
I need some help with Laravel. What I want to do is create a route filter that will redirect a user with a specified message passed from a variable. The code I currently have semi-works, the only that that I don't like though, is that the message gets converted to lowercase characters when displayed on the view.
Route::get('event/signup', array('before' => 'auth_message:You must be logged into your account to signup for the event.', 'uses' => 'event@signup'));
Route::filter('auth_message', function($message)
{
if (!Auth::user())
{
return Redirect::to('/')->with('errorAlert', $message);
}
});
So for example, this message "You must be logged into your account to signup for the event." is displayed as this on the view after the user is redirected: "you must be logged into your account to signup for the event." Is it possible to retain the character case?
Upvotes: 1
Views: 312
Reputation: 414
You are getting the wrong parameter from the filter. The following works like you would expect:
Route::filter('auth_message', function($route, $request, $value)
{
if (!Auth::user())
{
return Redirect::to('/')->with('errorAlert', $value);
}
});
Route::get('/', function(){
exit(Session::get('errorAlert')); // Returns "You must be logged into your account to signup for the event."
});
Upvotes: 1