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?
2
Answers
This method returns the route URI as it was defined in the routes file
Yes, you can get the route definition (including the placeholder like {variable}) using the following:
This will give you the route URI with the placeholders ({variable}), instead of the actual value passed in the request.
This will return the original route string with {variable} as part of it, which is what you are looking for.