Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filament Shield implementation error #13

Closed
z00f opened this issue Jul 1, 2023 · 9 comments · Fixed by #46
Closed

Filament Shield implementation error #13

z00f opened this issue Jul 1, 2023 · 9 comments · Fixed by #46
Assignees
Labels
bug Something isn't working

Comments

@z00f
Copy link

z00f commented Jul 1, 2023

Hi.
Does the plugin has Filament Shield implementation?
https://github.com/bezhanSalleh/filament-shield

It thows an error

Screenshot from 2023-07-01 11-50-16

@Jehizkia Jehizkia added the bug Something isn't working label Jul 3, 2023
@Jehizkia Jehizkia self-assigned this Jul 3, 2023
@Jehizkia
Copy link
Member

Jehizkia commented Jul 7, 2023

Well it has no specific implementation for the filament shield plugin, but I'll look into it!

@robertosanval
Copy link

I'm trying to use it with Filament Shield too but my error is when I try to edit a Role:

Cannot assign bool to property Filament\Resources\Pages\EditRecord::$data of type ?array

@Jehizkia
Copy link
Member

@robertosanval, I haven't used Shield yet, but I'll try to move it up on my list to check it out. If you have any ideas, feel free to make a pull request.

@eelco2k
Copy link

eelco2k commented Jan 6, 2024

i'm having the same issue:

debugbar gives me little more info:

Cannot assign bool to property Filament\Resources\Pages\EditRecord::$data of type ?array

./vendor/livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php#406
TypeError
    protected function setComponentPropertyAwareOfTypes($component, $property, $value)
    {
        try {
           $component->$property = $value;
        } catch (\TypeError $e) {
            // If an "int" is being set to empty string, unset the property (making it null).
            // This is common in the case of `wire:model`ing an int to a text field...

@eelco2k
Copy link

eelco2k commented Jan 6, 2024

Also i see in the ResourceLockResource.php that there are only to policies:

canViewAny() and canDeleteAny() instead of the default filament permission_prefixes.

for now i disabled the resource permissions in filament-shield.php config file by adding ResourceLockResource to the resources array:

'exclude' => [
        'enabled' => true,

        'resources' => [
            'ResourceLockResource',
        ],
    ],

it also helps mitigating this issue: #5

@eelco2k
Copy link

eelco2k commented Jan 6, 2024

perhaps it has to do with the package name and the way Shield package identifies the permission name:

see: https://github.com/bezhanSalleh/filament-shield?tab=readme-ov-file#configure-permission-identifier

the default permission identifier does some things with the string "Resource"

@eelco2k
Copy link

eelco2k commented Jan 6, 2024

yes the package namespace of ResourceLock in combination with the FilamentShield resource suffix for permissions makes this go wrong

You can fix it by adding this code to your AppServiceProvider.php boot() method:

FilamentShield::configurePermissionIdentifierUsing(fn ($resource) => return str($resource::getModel())->prepend('::')->toString());

This makes all your Resource permissions structure in the database column look like this:
for example:

view_any::Kenepa\ResourceLock\Resources\ResourceLockResource

@Jehizkia
Copy link
Member

Jehizkia commented Jun 7, 2024

Thank you for figuring this out @eelco2k !

@eelco2k
Copy link

eelco2k commented Jun 7, 2024

@Jehizkia Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants