Merge branch 'master' into theme-mods

This commit is contained in:
/SyntaxLexx
2023-06-10 03:44:07 +03:00
committed by GitHub
12 changed files with 11684 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ class BaseChartModel
use HasGrid;
use HasColors;
use HasTheme;
use HasJsonConfig;
public function __construct()
{
@@ -32,6 +33,7 @@ class BaseChartModel
$this->initGrid();
$this->initColors();
$this->initTheme();
$this->initJsonConfig();
}
public function reactiveKey()
@@ -52,6 +54,7 @@ class BaseChartModel
$this->gridToArray(),
$this->colorsToArray(),
$this->themeToArray()
$this->jsonConfigToArray()
);
}
@@ -67,5 +70,6 @@ class BaseChartModel
$this->gridFromArray($array);
$this->colorsFromArray($array);
$this->themeFromArray($array);
$this->jsonConfigFromArray($array);
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Asantibanez\LivewireCharts\Models;
trait HasJsonConfig
{
private $jsonConfig;
public function setJsonConfig($jsonConfig)
{
$this->jsonConfig = $jsonConfig;
return $this;
}
protected function initJsonConfig()
{
$this->jsonConfig = [];
}
private function defaultJsonConfig()
{
return [];
}
protected function jsonConfigFromArray($array)
{
$this->jsonConfig = data_get($array, 'jsonConfig', $this->defaultJsonConfig());
}
protected function jsonConfigToArray()
{
return [
'jsonConfig' => $this->jsonConfig,
];
}
}