Closed shebaoting closed 2 months ago
i don't know what's not clear in the docs but, to disable it in certain panels you just need to add the panel ids to the excludes()
method. so in any service provider's boot()
method
//XXServiceProvider
use BezhanSalleh\PanelSwitch\PanelSwitch;
...
public function boot(): void
{
PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
$panelSwitch->excludes(['app','customer_portal']); // the panel switch will not be rendered in these panels
// app and customer_protal are panel ids
});
}
i don't know what's not clear in the docs but, to disable it in certain panels you just need to add the panel ids to the excludes() method. so in any service provider's boot() method //XXServiceProvider
use BezhanSalleh\PanelSwitch\PanelSwitch; ... public function boot(): void { PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) { $panelSwitch->excludes(['app','customer_portal']); // the panel switch will not be rendered in these panels // app and customer_protal are panel ids }); }
That's not true, excludes will just keep the panel from appearing in the toggle button options.
But the top right toggle button is still there. I would like to have this toggle button not appear at all in the disabled panel. It's as if the extension was never installed.
我不知道文档中有什么不清楚的地方,但是要在某些面板中禁用它,只需将面板 ID 添加到
excludes()
方法中。因此,在任何服务提供商的boot()
方法中 //XX 服务提供商use BezhanSalleh\PanelSwitch\PanelSwitch; ... public function boot(): void { PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) { $panelSwitch->excludes(['app','customer_portal']); // the panel switch will not be rendered in these panels // app and customer_protal are panel ids }); }
That's not true, excludes will just keep the panel from appearing in the toggle button options.
But the top right toggle button is still there. I would like to have this toggle button not appear at all in the disabled panel. It's as if the extension was never installed.
My bad, my head was in a totally different space.
suppose you have 3 panels admin
, app
and sass
, now you want Language Switch to not be visible/enabled in the sass
and app
panels. So in any service provider's boot() method
//XXServiceProvider
use BezhanSalleh\PanelSwitch\PanelSwitch;
...
public function boot(): void
{
PanelSwitch::configureUsing(function (PanelSwitch $switch) {
$switch->visible(fn() => in_array(Filament::getCurrentPanel()->getId(), ['admin','test'])); // enabled for only these panels
// $switch->visible(fn() => !in_array(Filament::getCurrentPanel()->getId(), ['app','sass'])); // disabled for these panels
});
}
now depending on your use case, you might wanna exclude the panels panels which don't have the switch as well.
My bad, my head was in a totally different space. suppose you have 3 panels admin, app and sass, now you want Language Switch to not be visible/enabled in the sass and app panels. So in any service provider's boot() method //XXServiceProvider
use BezhanSalleh\PanelSwitch\PanelSwitch; ... public function boot(): void { PanelSwitch::configureUsing(function (PanelSwitch $switch) { $switch->visible(fn() => in_array(Filament::getCurrentPanel()->getId(), ['admin','test'])); // enabled for only these panels // $switch->visible(fn() => !in_array(Filament::getCurrentPanel()->getId(), ['app','sass'])); // disabled for these panels }); }
now depending on your use case, you might wanna exclude the panels panels which don't have the switch as well.
It is not possible to use Filament::getCurrentPanel()->getId()
in app/Providers/AppServiceProvider.php.
I have 4 panels [‘admin’, ‘customer’, ‘operation’, ‘dev’].
customer
is the default panel.
But even if I am in dev
panel, the panel id I get using the following code is always customer
dd(Filament::getCurrentPanel()->getId());
It prints out ascustomer
, notdev
.
我的错,我当时完全心不在焉。假设你有 3 个面板
admin
、app
和sass
,现在你希望在sass
和app
面板中不显示/禁用 Language Switch 。因此,在任何服务提供商的 boot()方法中 //XX 服务提供商use BezhanSalleh\PanelSwitch\PanelSwitch; ... public function boot(): void { PanelSwitch::configureUsing(function (PanelSwitch $switch) { $switch->visible(fn() => in_array(Filament::getCurrentPanel()->getId(), ['admin','test'])); // enabled for only these panels // $switch->visible(fn() => !in_array(Filament::getCurrentPanel()->getId(), ['app','sass'])); // disabled for these panels }); }
现在根据你的用例,你可能也想要排除那些没有开关的面板。
It is not possible to use
Filament::getCurrentPanel()->getId()
in app/Providers/AppServiceProvider.php.I have 4 panels [‘admin’, ‘customer’, ‘operation’, ‘dev’].
customer is the default panel.
But even if I am in dev panel, the panel id I get using the following code is always customer
dd(Filament::getCurrentPanel()->getId());
It prints out as customer, not dev.
Dude, use my code, forget about the dd()
you are obviously using it outside the configureUsing()
method. just say you don't want to see it in your customer and operation panels right:
PanelSwitch::configureUsing(function (PanelSwitch $switch) {
$switch->visible(fn() => !in_array(Filament::getCurrentPanel()->getId(), ['customer','operation']));
});
sometime just copy/paste and you will get what you want 😎
@bezhanSalleh It's working now. Thank you very much. I'm so stupid. Thank you very much.
@bezhanSalleh It's working now. Thank you very much. I'm so stupid. Thank you very much.
No worries, it happens to the best of us 🍻
What happened?
I would like to completely not show this extension in some panel. But I can't get the exact panel id in AppServiceProvider using Filament::getCurrentPanel()->getId(). so I can't hide it using visible either. I've looked at https://github.com/bezhanSalleh/filament-panel-switch/issues/26 but I still don't know how to fix my problem. Is there any way to easily and quickly disable this extension in a certain panel and not show it at all?
How to reproduce the bug
...
Package Version
1.0.6
PHP Version
8.3.0
Laravel Version
11.0
Which operating systems does with happen with?
No response
Notes
No response