bezhanSalleh / filament-shield

The easiest and most intuitive way to add access management to your Filament Admin Resources, Pages & Widgets through `spatie/laravel-permission`
MIT License
1.35k stars 166 forks source link

Model with two words has unexpected permission name #369

Closed scottgrayson closed 3 months ago

scottgrayson commented 3 months ago

Steps to reproduce:

  1. create a model with two words e.g. ZipCode
  2. edit a role and give permission to view any zip code.

result: new permission gets created called "view_any_zip::code"

expected: the existing permission "view_any_zip_code" should be attached to the role

bezhanSalleh commented 3 months ago

That's the default behavior, if you want to change it read Configure Permission Identifier docs section.

Raffi-001 commented 1 month ago

@bezhanSalleh I had the same issue I fixed it by Configuring Permission Identifier like you suggested.

However, the default behavior works only if the Model name is a single word.

Works for \App\Filament\Resources\ZipResource; \\ view_any_zip

But not for. Not technincal problem but the formatting is annoying \App\Filament\Resources\ZipCodeResource; \\ view_any_zip::code