Skip to content

Commit

Permalink
Merge pull request #10 from zsp03/excludes-closure
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh authored Oct 16, 2023
2 parents 25ed2fd + 66ea87e commit 68ef52e
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 68ef52e

Please sign in to comment.