
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
request()->path()
0Output:
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']);
Random Code Snippet Queries: Laravel
- How to generate .env file for laravel?
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- How to create static page in Laravel
- How to add unique records in pivot columns of Laravel pivot table
- Laravel create multiple records in Pivot table
- Get domain name in laravel
- The use statement with non-compound name 'Auth' has no effect
- Target class [HomeController] does not exist
- Order by multiple columns in Laravel
- Input file with max size validation in laravel
- Delete records with relationship in laravel
- Get last year created records in Laravel
- Laravel file size validation not working
- Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- Send post data from controller to view
- Laravel API response format
- External link not working in laravel blade
- Drop foreign key column in Laravel using migration
- Skip first n record and display rest records in laravel view
- Laravel save object to database
- Get comma separated email from input array
- Property [user] does not exist on this collection instance
- How to decrypt laravel password
- Credit card validation in laravel