skip to Main Content

I have one web route

Route::post('users/{id}', [UserController::class, 'show'])->name('user.show');

Now, I need to get the id key using the IlluminateSupportFacadesRoute class.

Is there any function that exists in the router that returns what we pass in the route binding?

2

Answers


  1. wherever in controller you can use the current request to do this:

    $id=request()->route('id');
    

    and thanks to Maksim’s comment below:
    in the blade view file you can use the request() like:

     {{ request()->route('id') }} 
    
    Login or Signup to reply.
  2. Route::input('id') would be the way to do it using the Route facade.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search