F
Filamentβ€’15mo ago
blakdronzer

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
Xe
Xeβ€’15mo ago
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
blakdronzer
blakdronzerOPβ€’15mo ago
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
Xe
Xeβ€’15mo ago
got you, you want to define everything on your own right like not amanageble ressource
blakdronzer
blakdronzerOPβ€’15mo ago
Yes Well if I get something surely will share with you
Xe
Xeβ€’15mo ago
I'd like to know, yeah,,
blakdronzer
blakdronzerOPβ€’15mo ago
There is a possibility I guess and that can be via observer
Xe
Xeβ€’15mo ago
But sorry, I have no info on how to implement that
blakdronzer
blakdronzerOPβ€’15mo ago
Will explore in sometime and see if that works No worries We all are learning
Xe
Xeβ€’15mo ago
weell, why not differentiating with an attribute? that was my first approach
blakdronzer
blakdronzerOPβ€’15mo ago
If there is anything from your end to share..that will be great
Xe
Xeβ€’15mo ago
well, my case says: it's either a super admin, or not,
blakdronzer
blakdronzerOPβ€’15mo ago
That's already done That's even simpler
Xe
Xeβ€’15mo ago
how did you do it?
blakdronzer
blakdronzerOPβ€’15mo ago
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
Xe
Xeβ€’15mo ago
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
blakdronzer
blakdronzerOPβ€’15mo ago
Well observer is second method I will look in to ..first I will try overriding the save method itself That might solve the issue
Lara Zeus
Lara Zeusβ€’15mo ago
you can also use hooks like 'beforeCreate'
blakdronzer
blakdronzerOPβ€’15mo ago
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
Want results from more Discord servers?
Add your server