
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 create project_user pivot table in laravel
- Trying to get property 'title' of non-object
- How to display a specific word from a string in laravel
- Delete records with relationship in laravel
- How to avoid duplicate entries in pivot table in Laravel
- Ignore Records where a field has NULL value in Laravel
- Credit card validation in laravel
- How to display order by null last in laravel
- Create project factory and seed data in laravel
- How to get last record from object collection in laravel
- Redirect to another view from controller in laravel
- Insert current date time in a column using Laravel
- Update record after find method in lavavel
- How to fetch single row data from database in laravel
- How to get IP address in laravel
- How to show data by ID in laravel?
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- How to get list of all views file in laravel
- How to check duplicate entry in laravel
- Print last executed query in laravel
- Display message with session flash using bootstrap alert class in laravel
- How to upload multiple images after preview in laravel using cropper js
- How to get random string in Laravel
- Get Array of IDs from Eloquent Collection
- How to validate website url in laravel using validaiton