Recipe: MoneyColumn
Display currency amounts with cents storage and ISO 4217 codes
What / When
Use MoneyColumn when cells are monetary amounts. Prefer it over NumberColumn plus custom JS.
Minimal Example
use Pentiminax\UX\DataTables\Column\MoneyColumn;
use Pentiminax\UX\DataTables\Column\TextColumn;
public function configureColumns(): iterable
{
yield TextColumn::new('name', 'Product');
yield MoneyColumn::new('price', 'Price')
->currency('EUR')
->storedAsCents();
}
protected function mapRow(mixed $row): array
{
return [
'name' => $row->getName(),
'price' => $row->getPriceInCents(), // e.g. 1999 → €19.99
];
}