How to sum a currency format? #847
-
Hi, I am totally confused about how to sum from a field that contains currency closure. I already follow some of these documentaries:
Also, I searched this issue in issues and discovered that it was a bug, and it has been closed. But none of those work for me. I also try it in powergrid demo, the problem still encounter
I tried this for calories or let's try to add currency from the "PRICE" column that has successfully shown the sum but doesn't have currency by default. Could someone please show me or provide the full code for adding currencies with sum? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @ivanfa5, Assuming you have these two columns, public function addColumns(): PowerGridEloquent
{
return PowerGrid::eloquent()
->addColumn('id')
//1000.00
->addColumn('price')
//R$ 1.000,00
->addColumn('price_BRL', fn (Dish $dish) =>'R$ ' . number_format(e($dish->price), 2, ',', '.'));
} You can then do: public function columns(): array
{
return [
Column::add()
->title(__('ID'))
->field('id', 'dishes.id')
->searchable()
->sortable(),
Column::add()
->title(__('Price'))
->field( 'price_BRL', 'price')
->withSum('Total em R$', true, true),
];
} I will update the doc to make it more clear 😊 |
Beta Was this translation helpful? Give feedback.
-
You can create a custom theme and change the CSS. For instance: //...
class MyTheme extends Tailwind
{
public string $name = 'tailwind';
public function table(): Table
{
return Theme::table('rounded-lg min-w-full border border-slate-200 dark:bg-slate-600 dark:border-slate-500')
//...
->tdBodyTotalColumns('px-3 py-2 whitespace-nowrap dark:text-slate-200 text-sm text-slate-600 text-left space-y-2'); //Align left
//... |
Beta Was this translation helpful? Give feedback.
You can create a custom theme and change the CSS.
For instance: