Skip to content

Commit

Permalink
allow closure on excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
zsp03 committed Oct 3, 2023
1 parent ee8cd3c commit 66ea87e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/PanelSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PanelSwitch
use Configurable;
use EvaluatesClosures;

protected array $excludes = [];
protected array | Closure $excludes = [];

protected bool | Closure | null $visible = null;

Expand Down Expand Up @@ -93,7 +93,7 @@ public function canSwitchPanels(bool | Closure $condition): static
return $this;
}

public function excludes(array $panelIds): static
public function excludes(array | Closure $panelIds): static
{
$this->excludes = $panelIds;

Expand Down Expand Up @@ -175,7 +175,7 @@ public function visible(bool | Closure $visible): static

public function getExcludes(): array
{
return $this->excludes;
return (array) $this->evaluate($this->excludes);
}

public function getModalHeading(): string
Expand Down Expand Up @@ -237,7 +237,7 @@ public function isVisible(): bool
public function getPanels(): array
{
return collect(filament()->getPanels())
->reject(fn (Panel $panel) => in_array($panel->getId(), $this->excludes))
->reject(fn (Panel $panel) => in_array($panel->getId(), $this->getExcludes()))
->toArray();
}

Expand Down

0 comments on commit 66ea87e

Please sign in to comment.