You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to implement feature to have 2 routes with same URI and on base some condition, i can redirect it to different route
example: Route::get('dashboard', [Controllers\Dashboard\Dashboard\AdminDashboardController::class, 'index'])->name('admin.dashboard-index')->middleware(Middleware\AdminAppMiddleware::class); Route::get('dashboard', [Controllers\Dashboard\Dashboard\StudentDashboardController::class, 'index'])->name('student.dashboard.index')->middleware(Middleware\StudenAppMiddleware::class);
It can be implemented in vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php
` protected function addToCollections($route)
{
$domainAndUriAndName = $route->getDomain().$route->uri() . $route->name();
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to implement feature to have 2 routes with same URI and on base some condition, i can redirect it to different route
example:
Route::get('dashboard', [Controllers\Dashboard\Dashboard\AdminDashboardController::class, 'index'])->name('admin.dashboard-index')->middleware(Middleware\AdminAppMiddleware::class); Route::get('dashboard', [Controllers\Dashboard\Dashboard\StudentDashboardController::class, 'index'])->name('student.dashboard.index')->middleware(Middleware\StudenAppMiddleware::class);
It can be implemented in vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php
` protected function addToCollections($route)
{
$domainAndUriAndName = $route->getDomain().$route->uri() . $route->name();
Actual version is:
` protected function addToCollections($route)
{
$domainAndUri = $route->getDomain().$route->uri();
so $this->allRoutes is unque by domain and uri. The name of route is not accepted as the key for routes collection.
After that, it can be possible to redirect to different route by some condition in middleware.
Beta Was this translation helpful? Give feedback.
All reactions