Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0
Solution

Input::get('age') will look for a variable named as 'age' in query string :

e.g, user/?age=220

But, you can access route parameters using first parameter of filter closure i.e, '$route':

//filters.php
Route::filter('old', function($route)
{
	if($route->getParameter('age') < 200 )
	{
		return 'Age is:'. $route->getParameter('age');
	}
});

//routes.php
Route::get('user/{age}', array('before' => 'old', function()
{
    return 'You are over 200 years old!';
}));
Last updated 2 years ago.
0

Ah, I see. Thanks for the reply

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.