Get the currently dispatched route instance.
public current ( ) : Illuminate\Routing\Route | ||
return | Illuminate\Routing\Route |
use Illuminate\Support\Facades\Route; Route::get('/users/{id}', function ($id) { $route = Route::getCurrentRoute(); // do something with the current route });
use Illuminate\Routing\Router; $router = app(Router::class); $currentRoute = $router->current();In this example, the Router instance is obtained from the application container and the `current()` method is called to get the currently matched route instance. This can be useful for getting information about the current route outside of a route closure.
public current ( ) : Illuminate\Routing\Route | ||
return | Illuminate\Routing\Route |