
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
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- How to add unique records in pivot columns of Laravel pivot table
- Touch parent updated_at in Laravel
- Property [user] does not exist on this collection instance
- Method Illuminate\Database\Eloquent\Collection::appends does not exist
- Drop foreign key column in Laravel using migration
- Class "App\Http\Controllers\Auth\Verified" not found
- Delete records with relationship in laravel
- Laravel change date format
- Pass value from controller to model in laravel
- Convert multidimensional array to single array in Laravel
- Laravel delete all rows older than 30 days
- Laravel migration add foreign key to existing table
- How to create event and listener in laravel ?
- How to pass data to route in laravel?
- Laravel specific table Migration
- How to pass data to multiple partial view files in laravel
- How to add dynamic page title in Laravel view
- How to start websocket server in laravel
- How to validate URL with https using regex in laravel
- How to get id of next record in laravel
- Get all users except the followings users in overtrue laravel-follow
- How to get laravel errors folder in views directory in laravel
- Display option of select as selected with blade directive Laravel
- How to upload multiple images after preview in laravel using cropper js