From 7fad21ddb0705395fcb6678985a63c1b35e6f652 Mon Sep 17 00:00:00 2001 From: eliseekn Date: Mon, 6 May 2024 04:15:18 +0000 Subject: [PATCH] Restore $missingDataLabels default value --- src/DatesFunctions.php | 5 ++++- src/LaravelMetrics.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/DatesFunctions.php b/src/DatesFunctions.php index 457c246..b656675 100644 --- a/src/DatesFunctions.php +++ b/src/DatesFunctions.php @@ -206,7 +206,10 @@ protected function getLabelsData(): array $result = []; $labelColumn = explode('.', $this->labelColumn)[1]; - $missingDataLabels = DB::table($this->table)->get()->pluck($labelColumn)->toArray(); + + $missingDataLabels = empty($this->missingDataLabels) + ? DB::table($this->table)->get()->pluck($labelColumn)->toArray() + : $this->missingDataLabels; foreach ($missingDataLabels as $label) { $result[$label] = $this->missingDataValue; diff --git a/src/LaravelMetrics.php b/src/LaravelMetrics.php index 3439b6c..906cc8e 100644 --- a/src/LaravelMetrics.php +++ b/src/LaravelMetrics.php @@ -53,6 +53,8 @@ class LaravelMetrics protected int $missingDataValue = 0; + protected array $missingDataLabels = []; + protected string $groupBy; public function __construct(protected Builder|QueryBuilder $builder) @@ -441,10 +443,11 @@ public function labelColumn(string $column): self return $this; } - public function fillMissingData(int $missingDataValue = 0): self + public function fillMissingData(int $missingDataValue = 0, array $missingDataLabels = []): self { $this->fillMissingData = true; $this->missingDataValue = $missingDataValue; + $this->missingDataLabels = $missingDataLabels; return $this; }