1
votes

How can I get Actual Route path From Route file in controller using Laravel 5.4

When i m using $url =$request->route()->getPath(); that occurs error message in laravel 5.4

message like that:

  • local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Routing\Route::getPath() in E:\xampp\htdocs\newneptune\app\Http\Middleware\rollwise.php:25 Stack trace:
3
Does $url = Route::getCurrentRoute()->getPath(); work?brombeer
No, its not Working.Ravi Thummar

3 Answers

2
votes

Instead of $request->route()->getPath() use $request->route()->uri()

1
votes

Use Route::getCurrentRoute()->getUri().

Hope this helps.

0
votes

Use getPathInfo():

$request->getPathInfo();

It will return URI without GET parameters if any.