change the color of the number if it is equal to 1 in laravel datatable PowerGrid

61 Views Asked by At

i am working with PowerGrid table, i need to create a condition to change the text color of the number if it is "1" in the column "send?".

enter image description here

  public function columns(): array
{
    return [


        Column::make('Invitado', 'invitado')
            ->sortable()
            ->searchable(),

        Column::make('Anticipada', 'anticipada')
            ->sortable()
            ->searchable(),

        Column::make('Whatsapp', 'whatsapp')
            ->sortable()
            ->searchable(),

        Column::make('Cantidad', 'cantidad'),
        Column::make('Estado', 'estado'),

        Column::make('Send?', 'send?'),

        Column::action('Action')
    ];
}
1

There are 1 best solutions below

0
Sammar malik On

This can be achieved by adding CSS classes to the span attribute based on the value of the column:

public function columns(): array
{
  return [
           ...
           ...
           Column::make('Send?', 'send?')->contentClasses([
                '1' => 'text-green-600',
                '0' => 'text-blue-600',
            ]),
           ...
   ]
}    

for reference: https://livewire-powergrid.com/table/include-columns.html#contentclasses