How can I make an attribute comparison?

1

How can I compare> 0 or

asked by anonymous 26.02.2016 / 00:04

1 answer

2

Assuming you are using a GridView in Yii2. In the 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.'
        }
    }
],
    
26.02.2016 / 13:45