what if a doctor is an admin too? I've come across situations like this.
I would say keep auth table simple (single 'users' table). and then attach models of each role to the user model. The user model will have relationships to patient, admin and doctor models.
Also Laravel supports authentication from multiple tables. If you want to use multiple tables.
Thanks for your answer! this is the way I'm trying it now, I'm just wondering how to make the routes? My DashboardController looks like this now, it's bad... but i'm wondering where to add that checking logic
class DashboardController extends Controller
{
public function index()
{
if(Auth::user()->hasRole('admin')) {
return view('admin.index');
}
if(Auth::user()->hasRole('dentist')) {
return view('doctor.index');
}
}
public function settings()
{
if(Auth::user()->hasRole('admin')) {
return view('admin.settings');
}
if(Auth::user()->hasRole('dentist')) {
return view('doctor.settings');
}
}
}
Because there will be routes like /dashboard/settings , that will be there for all roles.
Thanks for your time!
Assuming a dentist could be an admin as well, you could move the role check to the view (or use view composer)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community