Skip to content

Commit

Permalink
Merge pull request #12763 from billmn/fix-currency-format
Browse files Browse the repository at this point in the history
[2.X] Fix currency format
  • Loading branch information
danharrin committed May 13, 2024
2 parents 601631d + 7e588cb commit 995326f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/tables/config/tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
'date_time_format' => 'M j, Y H:i:s',
'time_format' => 'H:i:s',

/*
|--------------------------------------------------------------------------
| Default Currency
|--------------------------------------------------------------------------
|
| This is the currency that Filament will use to display amounts
| by default.
|
*/

'default_currency' => env('DEFAULT_CURRENCY', 'USD'),

/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
Expand Down
2 changes: 2 additions & 0 deletions packages/tables/docs/03-columns/02-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ use Filament\Tables\Columns\TextColumn;
TextColumn::make('price')->money('eur')
```

Alternatively, you can set the default currency through the environment variable `DEFAULT_CURRENCY`.

## Limiting text length

You may `limit()` the length of the cell's value:
Expand Down
2 changes: 1 addition & 1 deletion packages/tables/src/Columns/Concerns/CanFormatState.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function money(string | Closure | null $currency = null, bool $shouldConv
}

if (blank($currency)) {
$currency = env('DEFAULT_CURRENCY', 'USD');
$currency = config('tables.default_currency');
}

return (new Money\Money(
Expand Down

0 comments on commit 995326f

Please sign in to comment.