Dont.
Use a single guard and use roles to determine what people can do.
Use guards for different authentication methods not for different classes of user
I have the following role ("Admin", "JobCoach", "Company ", "Manager ") , How I can add them to guards in config\auth.php
Dont.
Use a single guard and use roles to determine what people can do.
Use guards for different authentication methods not for different classes of user
@Snapey if there any link for user role will help me
@Mona_Salih12 You can add columns to the user table with boolean flags for each role (allows one user to have many roles) or you can have a single field that contains a string identifying their role (user can only ever have one role) or you can implement a roles package such as Spatie Permissions
Thank you very much for your assistance. Could you please provide me with a link or some guidance on how to use guards? I appreciate your help in advance.
@Mona_Salih12 no because I think they add pointless complexity
@Snapey Many thanks
@Snapey hey snapey, I have a when we should use guards?
@Mona_Salih12 Just FYI, this forum being 9+ years old already has discussions on:
usage of authorization instead of multi guards to determine who can and cannot do something
also usage of multiple guards
in depth discussions of authentication and authorization in general (some very detailed).
But again just some fyi.
@amitsolanki24_ when you need different methods of authentication
@mona_salih12 Just use roles.
This topic has come up so many times that I wrote a blog post on it a while ago: https://martinbean.dev/blog/2021/07/29/simple-role-based-authentication-laravel/
Please or to participate in this conversation.