Files
filament/packages/forms/src/Components/Concerns/CanBeCloned.php
T

31 lines
607 B
PHP

<?php
namespace Filament\Forms\Components\Concerns;
use Closure;
trait CanBeCloned
{
protected bool | Closure $isCloneable = false;
public function cloneable(bool | Closure $condition = true): static
{
$this->isCloneable = $condition;
return $this;
}
public function isCloneable(): bool
{
if ($this->isDisabled()) {
return false;
}
if (filled($this->getMaxItems()) && ($this->getMaxItems() <= $this->getItemsCount())) {
return false;
}
return (bool) $this->evaluate($this->isCloneable);
}
}