Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Screen/Components/Cells/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -24,6 +25,7 @@ public function __construct(
protected ?string $thousands_separator = ',',
protected ?string $before = '',
protected ?string $after = '',
protected ?string $empty = '',
) {
}

Expand All @@ -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.' ')
Expand Down