问题
How could i hide the parameters of a get route in laravel 5?
I mean, a route can have required parameters, and also optional parameters, i would like to know how to hide that parameters.
Here's Laravel docs for Route parameters
You can capture segments of the request URI within your route:
Route::get('user/{id}', function($id) { return 'User '.$id; });
If my domain is: example.com, when i access to example.com/user/201348 i would like that in the browser the URL be: example.com/user for example.
回答1:
What you need is not a get route but a post route.
Route::get('user/', function(Request $request)
{
return 'User '.$request->get('id');
});
But keep in mind: You need to create a form to generate a post request.
{{ Form::open(array('url' => 'user')) }}
{{ Form::hidden('id', $userId); }}
{{ Form::submit('Show user with id '.$userId); }}
{{ Form::close() }}
来源:https://stackoverflow.com/questions/32076500/hide-required-parameters-of-routes-in-laravel-5-0