Use this syntax
Route::get('/{prefix}/dashboard', [Dashboard::class, 'dashboardRedirect'])->name('dashboard');
It's not available as the first parameter in the method
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone ,
I'm working on a web application in Laravel Livewire and i am struggling.
I have different user roles (admin, manager, doctor ect...) and want to redirect them into their dashboard within a prefix (e.g project.com/admin/dashboard | project.com/manager/dashboard).
I have tried in this way but i dont like it :
Route::group(['prefix' => 'manager'], function () {
Route::get('/dashboard', ManagerDashboard::class)->name('manager-dashboard');
});
Route::group(['prefix' => 'admin'], function () {
Route::get('/dashboard', AdminDashboard::class)->name('admin-dashboard');
});
ect...
Is there any method for a dynamic route prefix for example :
Route::get('/{$prefix}/dashboard', [Dashboard::class, 'dashboardRedirect'])->name('dashboard');
Thanks in advance!
Please or to participate in this conversation.