You will need to use .htaccess to change the legacy URL to a Laravel-friendly one.
Actually, you can make this work. You can't put query params in the route string, but you can use Input
(which is just a facade for Request
) to get them.
Route::get('products.php', function() {
if (Input::has('pid')) {
echo 'New Product ID: ' . Input::get('pid');
}
});
Hmmm.. Hamstu I put that code in my routes.php file and nothing outputs. I put an echo before the if and the echo appears but it doesn't appear to have access to any of the input vars inside the route file. Is there something special to do to make that happen?
I also tested this code which works but when i change products to products.php it finds the route but the echo of the input variables ends up blank no pid or variable. Its like its not reading the input variables when the route has a .php on it. Any ideas how to get past this other than using .htaccess file?
Route::get('products', function() {
echo Input::get('pid') . ' -' . Input::get('c');
});
hamstu said:
Actually, you can make this work. You can't put query params in the route string, but you can use
Input
(which is just a facade forRequest
) to get them.Route::get('products.php', function() { if (Input::has('pid')) { echo 'New Product ID: ' . Input::get('pid'); } });
Furthermore, stop doing all that stuff in your routes, rather route to your controller/method and get the
querystring string vars the right way..............
$ mynewvar = Input::get('whatever'); //from querystring
products.php?pid=x&flag=x
$ mypid = Input::get('pid');
etc, etc, etc.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community