
How to get route name on visit URL in laravel
How to get route name on visit URL in laravel
We will use programming in this lesson to attempt to solve the "How to get route name on visit URL in laravel".
You can get route name on visit URL in Laravel using request() method. You can use same code snippet in web.php, controller and view file to get the route name from URL In laravel-
Get route name using request() function on visit URL in laravel
//Syntax request()->route()->getName() //Demo code with output Route::get('/get-route-name', function(){ echo request()->route()->getName(); })->name('route.name');
Output:
route.name
This code snippet will help you to get the route name on visit a specific url in laravel. You have to just pass the name to route using name method while defining the route in web.php file.
Just copy/paste code in route\web.php file and visit /get-route-name url after running php artisan serve command to get the current route name.
-
Get route name using request() method on visit URL in laravel view
{{ request()->route()->getName() }}
Output:
home
Using this code snippet you can get the route name of current URL in laravel blade (view) file. You have to just specify the name for a route using name method on route definition in web.php.
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
- Display message with session flash using bootstrap alert class in laravel
- Laravel specific table Migration
- Create project factory and seed data in laravel
- How to create projects method with belongstomany relationship in user model
- Delete file from amazon s3 bucket using Laravel
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- Laravel pagination links with query string
- Pass value from controller to model in laravel
- How to display pivot table column value in laravel
- How to validate form input data in laravel
- Laravel upload file with original file name
- How to get only time from created_at in laravel
- How to check find method executed successfully in laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- Laravel 5.4 save data to database
- Add a subselect based on relationship using withAggregate method
- How to remove P tag from CkEditor in Laravel?
- Create project table with model and migration
- Eager loading dynamically in laravel
- How to get database name in Laravel 9 ?
- Comment .env file in laravel
- How to get tomorrow and yesterday date in laravel
- Class App\Http\Controllers\Admin\UserController Does Not Exist
- How to Get records between two dates in Laravel
- Extract only time from datetime in laravel