Is it possible to share resources, pages and widgets across panels?
Since now we can have multiple panels, and each panel uses:
Is there a way to share resources among panels? Example:
Sales & customer support should be able use
SalesResource
and OrdersWidget
.
If no such thing is possible. I'd like to collaborate on adding this feature.17 Replies
You can use
–>resources()
, ->pages()
and ->widgets()
to register custom resources/pages/widget for each panel.Is there any doc or code example you may kindly share?
It works the same way as any other configuration here:
https://filamentphp.com/docs/3.x/panels/configuration
I just put them in another folder "Shared" and register or extend from there
by extend you mean I can add
->discoverResources()
more than once?Extend as in Class inheritance.
Hi @Dennis Koch is this possible to have more details about this (your last message) ?
I have empty classes that extend source classes in a shared folder.
Ok so for example in my "admin" panel I have a AdressResource with a form, table, etc. I want this resource also in my "app" panel, so I share it with the
However I want to have a different form in the "app" panel, so I can extend the resource for defining a new form, but with the same resource ?
Yes, you could do it that way. Extend the base resource, overwrite the form and register the new Resource
Oh ok, so it looks like that ?
And what do you mean by registering the new Resource ? If I register AppAdressResource as a new resource, the records are still going to go in the same database table than AdressResource ?
Sure, they both use the same model
Oh nice, it's perfect 🙂 Its a lot better than doing this, when you have mutilple changes
Thank you so much
I created the AppFooResource extends FooResource but now I have two time the resource ... Probably because I have the one I share in the AppPanelProvider ->resources([]) and the one I create extending the FooResource class from the Admin panel 😦
And the resource in my admin panel is also impacted hmm ... Looks like there is no other option than ->visible
Don't understand your setup. Shouldn't be an issue of you don't register both in the same panel
I'm going to make a little diagram or something like that for better understanding and I will comeback to you 🙂
@Dennis Koch Hi, here is the little schema for explaining what I try to do. Idk if it really helps 😅
@Dennis Koch great thread, simple but very powerful