Added shades support in trait

This commit is contained in:
asantibanez
2022-02-14 15:37:59 -05:00
parent 52abe77e7e
commit 4a74606e4d

View File

@@ -8,6 +8,8 @@ trait HasColors
{
private $colors;
private $enableShades;
public function setColors($colors)
{
$this->colors = $colors;
@@ -22,9 +24,25 @@ trait HasColors
return $this;
}
public function enableShades()
{
$this->enableShades = true;
return $this;
}
public function disableShades()
{
$this->enableShades = false;
return $this;
}
protected function initColors()
{
$this->colors = $this->defaultColors();
$this->enableShades = true;
}
private function defaultColors()
@@ -35,12 +53,15 @@ trait HasColors
protected function colorsFromArray($array)
{
$this->colors = data_get($array, 'colors', $this->defaultColors());
$this->enableShades = data_get($array, 'enableShades', true);
}
protected function colorsToArray()
{
return [
'colors' => $this->colors,
'enableShades' => $this->enableShades,
];
}
}