
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');
0Output:
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() }}
0Output:
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.
Random Code Snippet Queries: Laravel
- How to delete record in Laravel with ajax
- Extra Filter Query on Relationships in Laravel
- Get latest record by created at in Laravel
- Laravel get all records with pagination
- How to pass external link in laravel blade to anchor tag
- How to get route method name in Laravel
- Call to a member function getRelationExistenceQuery() on array in Laravel
- How to pass data to route in laravel?
- How to create controller in laravel
- Trying to access array offset on value of type null error in laravel
- How to pass variable from controller to model in Laravel
- How to add columns in existing table using migration in laravel
- First and last item of the array using foreach iteration in laravel blade
- Argument 1 passed to App\Http\Controllers\Auth\LoginController::authenticated() must be an instance of App\Http\Controllers\Auth\Request
- Json encode method in laravel
- Order by multiple columns in Laravel
- Remove array keys and values if it does not exist in other array in Laravel
- How to get count of all records created at yesterday
- Class "App\Http\Controllers\Auth\Verified" not found
- The POST method is not supported for this route. Supported methods: PUT.
- Target class [HomeController] does not exist
- There are no commands defined in the "route:" namespace
- How to add a key value pair to existing array in laravel
- Delete file from amazon s3 bucket using Laravel
- Shorter syntax for whereHas with call back function in laravel