Laravel 5 getting ID from URL

This is late. But for the benefit of others like me;

If you do not have to do it in a method like the answers above have shown, As of Laravel 5.0 (Not sure about previous versions), you can do

$request->route('id');

That returns the value of the id parameter on the route.


Or just use it within Blade: {{ request()->route('id') }}


Basically when you are defining the routes, you use something called route parameters, something like this

Route::get('/visit/{id}', 'Controller@someMethod');

This id will be available as a parameter in your handler funtion,

public function someMethod($id) {
    // you have the id here
}