Skip to content

Commit 7fad21d

Browse files
committed
Restore $missingDataLabels default value
1 parent 9d1d86d commit 7fad21d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/DatesFunctions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ protected function getLabelsData(): array
206206
$result = [];
207207

208208
$labelColumn = explode('.', $this->labelColumn)[1];
209-
$missingDataLabels = DB::table($this->table)->get()->pluck($labelColumn)->toArray();
209+
210+
$missingDataLabels = empty($this->missingDataLabels)
211+
? DB::table($this->table)->get()->pluck($labelColumn)->toArray()
212+
: $this->missingDataLabels;
210213

211214
foreach ($missingDataLabels as $label) {
212215
$result[$label] = $this->missingDataValue;

src/LaravelMetrics.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class LaravelMetrics
5353

5454
protected int $missingDataValue = 0;
5555

56+
protected array $missingDataLabels = [];
57+
5658
protected string $groupBy;
5759

5860
public function __construct(protected Builder|QueryBuilder $builder)
@@ -441,10 +443,11 @@ public function labelColumn(string $column): self
441443
return $this;
442444
}
443445

444-
public function fillMissingData(int $missingDataValue = 0): self
446+
public function fillMissingData(int $missingDataValue = 0, array $missingDataLabels = []): self
445447
{
446448
$this->fillMissingData = true;
447449
$this->missingDataValue = $missingDataValue;
450+
$this->missingDataLabels = $missingDataLabels;
448451

449452
return $this;
450453
}

0 commit comments

Comments
 (0)