How can I compare the attribute?

Asked

Viewed 51 times

1

How can I compare >0 or <0 between these attributes in Yii?

[
    'attribute' => 'gross_total',
    'header' => 'ENTRADAS'
],

[
    'attribute' => 'gross_total',
    'header' => 'SAÍDAS'
],

1 answer

2


Assuming you are using a Gridview in Yii2. In the property value of column, you can use a closure and make the comparison:

[
    'attribute' => 'gross_total',
    'header' => 'SAÍDAS',
    'value' => function ($model, $key, $index, $column) {
        if($model->gross_total > 0){
            return 'Gross total maior que zero.'
        }
    }
],

Browser other questions tagged

You are not signed in. Login or sign up in order to post.