Search code examples
laravelroutes

Get path without arguments


In my api.php file, I might have a path that says Route::post('/this/thing/{variable}'

In another part of my codebase, when a request is made to that route, I can get the actual requested route with $request->path();, but if I do that, {variable} is of course replaced by whatever the request route actually put in there.

I want a $request->path() alternative that gives me the string '/this/thing/{variable}' without replacing {variable}, is that possible?


Solution

  • $routePath = $request->route()->uri();
    

    This method returns the route URI as it was defined in the routes file