Hide required parameters of routes in Laravel 5.0

2019-09-13 18:21发布

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条回答
甜甜的少女心
2楼-- · 2019-09-13 19:06

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() }}
查看更多
登录 后发表回答