From 0a5217b0223320c6012e40e7ad1a76d5007f31af Mon Sep 17 00:00:00 2001 From: Massimiliano Modena Date: Sun, 21 Jan 2024 12:57:59 +0100 Subject: [PATCH] don't needed crash if value is empty --- src/Screen/Components/Cells/Currency.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Screen/Components/Cells/Currency.php b/src/Screen/Components/Cells/Currency.php index 570041974..819757405 100644 --- a/src/Screen/Components/Cells/Currency.php +++ b/src/Screen/Components/Cells/Currency.php @@ -16,6 +16,7 @@ class Currency extends Component * @param string|null $thousands_separator * @param string|null $before * @param string|null $after + * @param string|null $empty string value if empty */ public function __construct( protected float $value, @@ -24,6 +25,7 @@ public function __construct( protected ?string $thousands_separator = ',', protected ?string $before = '', protected ?string $after = '', + protected ?string $empty = '', ) { } @@ -34,7 +36,12 @@ public function __construct( */ public function render() { - $value = number_format($this->value, $this->decimals, $this->decimal_separator, $this->thousands_separator); + if(empty($this->value)) { + $value = $this->empty; + } + else { + $value = number_format($this->value, $this->decimals, $this->decimal_separator, $this->thousands_separator); + } return Str::of($value) ->prepend($this->before.' ')