Use many guards, or make things simple and use authorization to determine who can and cannot do something.
You can make custom dashboards for certain role types, I have one separate for accounting and one for admin in one app.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi I would like to create a multi user app, using the breeze scaffolding.
I have added a field in the user table user_type, admin=0 user=1 agent=2 I have created the following folder structure:
Views/admin/dashboard Views/admin/editprofile Views/partials/ with the 3 files provided by breeze
Views/user/dashboard Views/user/editprofile Views/user/ with the 3 files provided by breeze
Views/agent/dashboard Views/agent/editprofile Views/agent/ with the 3 files provided by breeze
I have created the different user Routes, in web
I have tried using chatGPT to help create the login logic, however we end up going around in circles.
One suggestions was using routes
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/dashboard', function () {
$userType = auth()->user()->user_type;
switch ($userType) {
case 0: // admin
return redirect()->route('admin.dashboard');
case 1: // user
return redirect()->route('user.dashboard');
case 2: // manager
return redirect()->route('manager.dashboard');
case 3: // agent
return redirect()->route('agent.dashboard');
default:
return redirect('/');
}
})->name('dashboard');
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
});
Another was to edit the AuthenticatedSessionController which looked promising but both produced a number of errors which we tried to solve but ended up going around in circles.
protected function redirectBasedOnUserType(): RedirectResponse
{
$user = Auth::user();
$userType = $user->user_type;
switch ($userType) {
case 0: // admin
return redirect()->route('admin.dashboard');
case 1: // user
return redirect()->route('user.dashboard');
case 2: // manager
return redirect()->route('manager.dashboard');
case 3: // agent
return redirect()->route('agent.dashboard');
default:
return redirect('/');
}
}
Does anyone have a solution to this or a guide someone has created, I did google but nothing that helped, I don't want multi tables, just the user_type
thanks
Please or to participate in this conversation.