Skip to content

Commit

Permalink
Restore $missingDataLabels default value
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseekn committed May 6, 2024
1 parent 9d1d86d commit 7fad21d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/DatesFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/LaravelMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class LaravelMetrics

protected int $missingDataValue = 0;

protected array $missingDataLabels = [];

protected string $groupBy;

public function __construct(protected Builder|QueryBuilder $builder)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7fad21d

Please sign in to comment.