JosephSilber / bouncer

Laravel Eloquent roles and abilities.
MIT License
3.43k stars 330 forks source link

Ability Cast Blocks UUID on 'entity_id' #626

Open SMPEJake opened 1 year ago

SMPEJake commented 1 year ago

Hello! Thanks for the great library!

Just trying to make this work with models that use UUID's, i have updated the entity_id columns on the database tables to the UUID column but there appears to be an issue. There is currently a cast in the Ability Model for entity_id which casts it to int, this cast blocks the UUID's working properly.

Would there be any problems with removing the cast?

JosephSilber commented 1 year ago

Seems logical. You should be able to just change the casts in your custom models.

lrljoe commented 1 year ago

I've been using this with uuid based entities (user, team(scope) and entity) for an age, great package.

It works perfectly well, however I did hit a snag with the clipboard with a particularly complex custom scope using an array of UUIDs, can't remember what I did to fix it (from vague memory it was field length), but if you experience an issue then please @ me and I'll try to give you a steer.

@JosephSilber appreciate you've gotten this far without a config file which I'm suitably impressed with. But what would your feelings be on a config option to enable uuids (so the command generates a uuid migration, and switches the model casts to uuid compliant). Not volunteering to do this immediately as I'll need to go back through what I've done and triple check it.