F
Filamentβ€’4mo ago
GavTheDev

Switch between 2 types of sellers in same panel?

I'm looking to recreate similar functionality to Fiverr's seller and buyer profiles, if anyone's familiar with that. I don't have sellers and buyers, but rather 2 types of sellers (designers and manufacturers), and I would like users to be able to switch between them, using the same user account. For this I have created a seller panel in my app. I currently have a designer navigationGroup, and a manufacturer navigationGroup, but there is, or seems to be, no way of conditionally hiding/showing navigationGroups. A designer should see only the designer navigationGroup, a manufacturer only the manufacturer navigationGroup. But it's also possible that they are both, so a seller should see both navigationGroups. How can I conditionally load different resources/pages for different types of sellers? I guess I could create 2 separate panels, but they should share user login information, and I'm not sure this is possible. Could use some ideas πŸ˜…
Solution:
Solved it by creating a DesignerPage and ManufacturerPage with a shouldRegisterNavigation() and extend the other pages from that: ```php class DesignerPage extends Page { ...
Jump to solution
2 Replies
Tieme
Tiemeβ€’4mo ago
It is better to use 1 panel and create roles for the user. And set the correct permission for the resources and navigation with something like following plugin to create the roles and permissions. https://filamentphp.com/plugins/bezhansalleh-shield
Filament
Shield by Bezhan Salleh - Filament
The easiest and most intuitive way to add access management to your Filament Panel's Resources, Pages & Widgets through spatie/laravel-permission.
Solution
GavTheDev
GavTheDevβ€’4mo ago
Solved it by creating a DesignerPage and ManufacturerPage with a shouldRegisterNavigation() and extend the other pages from that:
class DesignerPage extends Page
{
public static function shouldRegisterNavigation(): bool
{
if (Filament::auth()->user()->designer) {
return true;
}

return false;
}
}
class DesignerPage extends Page
{
public static function shouldRegisterNavigation(): bool
{
if (Filament::auth()->user()->designer) {
return true;
}

return false;
}
}
Could probably be done better, but for now it works 😎