mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
Merge pull request #15817 from binaryfire/panel-default-closure
Modify panel default() method to accept closure
This commit is contained in:
@@ -45,7 +45,7 @@ class Panel extends Component
|
||||
use Panel\Concerns\HasUnsavedChangesAlerts;
|
||||
use Panel\Concerns\HasUserMenu;
|
||||
|
||||
protected bool $isDefault = false;
|
||||
protected bool | Closure $isDefault = false;
|
||||
|
||||
/**
|
||||
* @var array<array-key, Closure>
|
||||
@@ -57,7 +57,7 @@ class Panel extends Component
|
||||
return app(static::class);
|
||||
}
|
||||
|
||||
public function default(bool $condition = true): static
|
||||
public function default(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->isDefault = $condition;
|
||||
|
||||
@@ -116,6 +116,6 @@ class Panel extends Component
|
||||
|
||||
public function isDefault(): bool
|
||||
{
|
||||
return $this->isDefault;
|
||||
return (bool) $this->evaluate($this->isDefault);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user