How to get path from current URL in Laravel
How to get path from current URL in Laravel
In this session, we’ll try our hand at solving the "How to get path from current URL in Laravel" puzzle by using the computer language.
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-
Get path from current URL using request method in laravel
request()->path()
Output:
get-all-users
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']);
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Laravel route parameter
- How to check find method executed successfully in laravel
- How to get all route list
- Comment .env file in laravel
- Laravel append URI in route
- Route not defined in Laravel
- Insert Comma Separated Values in laravel
- How to get specific columns using with method in laravel Eloquent relationship
- Submit form without CSRF token in Laravel
- How to send ID to another page in Laravel
- Touch parent updated_at in Laravel
- How to get last year records count with month wise in Laravel
- How to remove P tag from CkEditor in Laravel?
- Laravel 9 route group with controller
- How to get column names from table in Laravel
- Class 'Facade\Ignition\IgnitionServiceProvider' not found
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- Method Illuminate\Database\Eloquent\Collection::lists does not exist
- Create project table with model and migration
- Laravel get all records with pagination
- Post model with title and body in laravel 8
- How to get last record from object collection in laravel
- Import/Use Storage facade in laravel
- On delete set foreign id column value null using migration in laravel 8
- How to create laravel project using composer