Extracted title property to trait

This commit is contained in:
Andrés Santibáñez
2020-11-03 07:20:46 -05:00
parent 22b72c1980
commit 63fe7a1533
6 changed files with 43 additions and 57 deletions

View File

@@ -9,8 +9,6 @@ namespace Asantibanez\LivewireCharts\Models;
*/
class AreaChartModel extends BaseChartModel
{
public $title;
public $color;
public $data;
@@ -21,8 +19,6 @@ class AreaChartModel extends BaseChartModel
{
parent::__construct();
$this->title = '';
$this->color = '#90cdf4';
$this->onPointClickEventName = null;
@@ -30,13 +26,6 @@ class AreaChartModel extends BaseChartModel
$this->data = collect();
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function setColor($color)
{
$this->color = $color;
@@ -65,7 +54,6 @@ class AreaChartModel extends BaseChartModel
public function toArray()
{
return array_merge(parent::toArray(), [
'title' => $this->title,
'color' => $this->color,
'onPointClickEventName' => $this->onPointClickEventName,
'data' => $this->data->toArray(),
@@ -76,8 +64,6 @@ class AreaChartModel extends BaseChartModel
{
parent::fromArray($array);
$this->title = data_get($array, 'title', '');
$this->color = data_get($array, 'color', '#90cdf4');
$this->onPointClickEventName = data_get($array, 'onPointClickEventName', null);