How to get path from current URL in Laravel

You can get path from current URL in Laravel using path() method on request() in Laravel. Path is URL without domain and query string value

Answers 1
  • Get path from current URL using request method in laravel




    It returns the path of url (without domain and query string values). You can use above code snippet in web.php, controller files and also in views file in laravel.

    Here, we have web route to implement above code snippet.

    Route::get('get-all-users', [HomeController::class, 'getAllUsers']);
  • Back to code snippet queries related laravel