bezhanSalleh/filament-shield

Permissions and roles not visible

AnassGBNL opened this issue · 3 comments

Issue: Filament Shield - Permissions and Roles for Models Without Filament Resources Not Visible or Manageable

Hi there,

I’m currently using the Filament Shield package in my application, and I’ve run into an issue that I can’t seem to resolve. I’m hoping someone here can help me figure out what might be going wrong, or if I’m simply missing something in my setup.

Background:

My application has a Filament admin panel where I handle most of the backend management, as well as a Livewire-powered frontend. I have several models in my application, but not all of them are represented by a Filament resource. For example, some models are only used on the frontend, while others—such as users, roles, and permissions—need to be managed from the admin panel.

To make managing permissions easier, I’m using Filament Shield. I ran the following command to generate permissions and roles for all my models:

php artisan shield:generate --all

However, after running this, I only see permissions and roles for the models that have a Filament resource. The models that don’t have an associated Filament resource are not listed or manageable from the Shield interface.

What I tried:

I thought maybe I could create the permissions and roles manually using the underlying Spatie package, as I’ve worked with that before and found it relatively straightforward. The manual creation of permissions and roles worked fine, and the permissions and roles were successfully created in the database.

However, even though the permissions and roles are created, they still do not show up in the Filament Shield interface. It’s as if the Shield plugin does not recognize them unless they are tied to a specific Filament resource.

My Question:

Am I doing something wrong here? Is it not possible to manage permissions and roles for models that don’t have a Filament resource using Filament Shield? Shouldn’t manually created permissions and roles still be visible and manageable through the admin panel?

I’d really appreciate any guidance on whether this is a limitation of Filament Shield or if there’s a workaround or configuration setting that I’m missing.

Thanks in advance for any help!

Best regards,
Anass

This is not an issue, because filament-shield only generate policies for models on filament resources.
You need to follow spacie/permisson's doc for the others models

what should i do to fix it

Issue: Filament Shield - Permissions and Roles for Models Without Filament Resources Not Visible or Manageable

Hi there,

I’m currently using the Filament Shield package in my application, and I’ve run into an issue that I can’t seem to resolve. I’m hoping someone here can help me figure out what might be going wrong, or if I’m simply missing something in my setup.

Background:

My application has a Filament admin panel where I handle most of the backend management, as well as a Livewire-powered frontend. I have several models in my application, but not all of them are represented by a Filament resource. For example, some models are only used on the frontend, while others—such as users, roles, and permissions—need to be managed from the admin panel.

To make managing permissions easier, I’m using Filament Shield. I ran the following command to generate permissions and roles for all my models:

php artisan shield:generate --all

However, after running this, I only see permissions and roles for the models that have a Filament resource. The models that don’t have an associated Filament resource are not listed or manageable from the Shield interface.

What I tried:

I thought maybe I could create the permissions and roles manually using the underlying Spatie package, as I’ve worked with that before and found it relatively straightforward. The manual creation of permissions and roles worked fine, and the permissions and roles were successfully created in the database.

However, even though the permissions and roles are created, they still do not show up in the Filament Shield interface. It’s as if the Shield plugin does not recognize them unless they are tied to a specific Filament resource.

My Question:

Am I doing something wrong here? Is it not possible to manage permissions and roles for models that don’t have a Filament resource using Filament Shield? Shouldn’t manually created permissions and roles still be visible and manageable through the admin panel?

I’d really appreciate any guidance on whether this is a limitation of Filament Shield or if there’s a workaround or configuration setting that I’m missing.

Thanks in advance for any help!

Best regards, Anass

As it states shield only generates permissions for filament components (Resources, Pages, Widgets). so if your models aren't utilized by resources shield won't touch 'em. So generate permissions and policies for them your self and then they will show up on the Custom Permissions tab in shield. if you want to have them grouped like Resources tab then you got to make resources for them. Shield will have an opt-in option for standalone models in the future but right now, i don't have the time to make it happen. Also if you could, these are basically questions and if you are on discord just ask them on the shield's channel to get a quick response. Thanks.