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
- Touch parent updated_at in Laravel
- How to check find method executed successfully in laravel
- Get comma separated email from input array
- Get laravel version
- How to pass data to multiple partial view files in laravel
- Undefined property: stdClass::$title
- Print last executed query in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Run artisan command to generate key in laravel
- Update last created record in Laravel
- Save or update pivot table data with additional column in Laravel
- How to upload files to amazon s3 bucket using Laravel
- Call to a member function pluck() on array
- How to add a key value pair to existing array in laravel
- Retain selected value of select box in Laravel
- Php artisan make model, factory, migration and controller in single command
- Get products with number of orders in Laravel
- Laravel insert query not working
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- Get content from web URL in laravel
- How to validate URL with https using regex in laravel
- Laravel 9 route group with controller
- Method Illuminate\Http\Request::validated does not exist
- How to pass query string to url in laravel
- How to create and run user seeder in laravel