![Logo loader icon](https://w3codegenerator.com/img/logo-f2.png)
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
- How to pass query string with pagination in laravel
- How to get date from created_at field in laravel
- How to get last month records in Laravel
- How to customize pagination view in laravel
- Create record with unique slug in laravel
- How to use more than one query scope in Laravel
- Extra Filter Query on Relationships in Laravel
- Eager loading dynamically in laravel
- How to upload files to amazon s3 bucket using Laravel
- On delete set foreign id column value null using migration in laravel 8
- Argument 1 passed to Illuminate\Database\Query\Builder::cleanBindings() must be of the type array, null given
- Shorter syntax for whereHas with call back function in laravel
- Non-static method App\Http\Helper::myFunction() should not be called statically
- How to set column as primary key in Laravel model
- Global scope in Laravel with example
- How to add background image to div using Tailwindcss, Vite in Laravel Environment
- Always load the relationship data with eager loading in Laravel
- How to check data inserted or deleted in pivot after toggle method
- Show old value while editing the form in Laravel
- How to get route method name in Laravel
- How to get IP address in laravel
- Get count of filter data, while return a small set of records
- Get laravel version
- Post model with title and body in laravel 8
- How to validate website url in laravel using validaiton