RFFRED
1 month ago
315
4
Laravel

Admin models and relationships

Posted 1 month ago by RFFRED

Hi,

i have an admin model which I use to login to my site. I have 6 different types of administrator and their roles/permissions are managed by spatie/permission.

They all run from the same "admin" model and now, I need to give different relationships to my admins towards other models.

For example, my "super admin" does not need any relationship to my "client" model but my "client admin" needs a one-to-one relationship to my "client" model and my "advisor" also needs a one-to-one relationship to my "client" model, plus a one-to-many relationships with my "institution" model

I am thinking creating "client admin", "advisor" models which would extend my "admin" model

I would still be able to login using the "admin" model.

I am not sure how I go from there because If I log in with an "advisor" user and use

Auth::guard('admin')->user()->

it will point to the "admin" model because this is what I use to run the login check using laravel/UI.

What''s the best way to access the function of the extended class?

Please sign in or create an account to participate in this conversation.