mirror of
https://github.com/filamentphp/filament.git
synced 2026-08-30 17:07:25 +08:00
31 lines
607 B
PHP
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);
|
|
}
|
|
}
|