Skip to content

Commit 7623e6d

Browse files
committed
fix: Issue
Issue #1956
1 parent d2f65f9 commit 7623e6d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Components/Metrics/Wrapped/Metric.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ abstract class Metric extends MoonShineComponent implements HasIconContract, Has
2222
use WithLabel;
2323
use WithIcon;
2424

25+
protected Color $iconColor = Color::PRIMARY;
26+
2527
final public function __construct(Closure|string $label)
2628
{
2729
parent::__construct();
2830

2931
$this->setLabel($label);
3032
}
3133

34+
public function iconColor(Color $color): static
35+
{
36+
$this->iconColor = $color;
37+
38+
return $this;
39+
}
40+
3241
protected function prepareBeforeRender(): void
3342
{
3443
$this->customAttributes([
@@ -44,7 +53,7 @@ protected function systemViewData(): array
4453
return [
4554
...parent::systemViewData(),
4655
'label' => $this->getLabel(),
47-
'icon' => $this->getIcon(6, Color::SECONDARY),
56+
'icon' => $this->getIcon(6, $this->iconColor),
4857
'columnSpanValue' => $this->getColumnSpanValue(),
4958
'adaptiveColumnSpanValue' => $this->getAdaptiveColumnSpanValue(),
5059
];

src/Traits/Fields/RangeTrait.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ protected function resolveOnApply(): ?Closure
207207
return $item;
208208
}
209209

210+
if (\is_array($values) && array_filter($values) === [] && $this->isNullable()) {
211+
data_set($item, $this->getFromField(), null);
212+
data_set($item, $this->getToField(), null);
213+
214+
return $item;
215+
}
216+
217+
if (\is_array($values) && array_filter($values) === []) {
218+
return $item;
219+
}
220+
210221
data_set($item, $this->getFromField(), $values[$this->getFromField()] ?? '');
211222
data_set($item, $this->getToField(), $values[$this->getToField()] ?? '');
212223

0 commit comments

Comments
 (0)