Help for Roles / Permission for user
I was working on creating roles / permission management for users via filamentphp 3 - now the issue here is the relationship with tables. There are 2 important aspect to understand ...
1 - in the mode relation table with permission / role - there is a key that needs to be set - model_type
2 -in the same - also set the team_id by default
Can anyone help as how can i set the same via filamentphp ?
18 Replies
I've actually been struggling with that too,
@blakdronzer how did you do it?
I'm using V2, I only needed to use the Filament-Shield package, manages a lot of that for you
Well sheild is fine for development...as for if I am building a package/ application where I give user the control to create role assign role / permission to the user it ain't the same...
For them ..they won't understand as what to do with those sheilds .... I wanted to make it simple ..i am looking to work around a solution..let's see how I can..
I tried digging deep in the permissions code too ..but didn't get much super help ... ofcourse ain't that great with eloquent yet
got you, you want to define everything on your own right
like not amanageble ressource
Yes
Well if I get something surely will share with you
I'd like to know, yeah,,
There is a possibility I guess and that can be via observer
But sorry, I have no info on how to implement that
Will explore in sometime and see if that works
No worries
We all are learning
weell, why not differentiating with an attribute?
that was my first approach
If there is anything from your end to share..that will be great
well, my case says:
it's either a super admin, or not,
That's already done
That's even simpler
how did you do it?
I can add user type as attribute to user table itself
Well but the main challenge is to add it to appropriate permission/ roles to user ...I think I might find a crack
.
Give me sometime..I will be back with some exploration
And share with you
you're the one who asked dude π let's think together
If you want to have control on the input, I mean, the type is a string, and you want to decide what exactly is written there, just make it a select
idk if you're creating users from your panel, or it's the user app that sends the requests
Well observer is second method I will look in to ..first I will try overriding the save method itself
That might solve the issue
you can also use hooks like 'beforeCreate'
well.. this was more dealing with saving relations ..rather then just handling before create
thats why i doublt if that will work - i need the created user id before i can save in the relations