I am displaying some columns in Yii2 GridView widget, 'Executive Name' is one of those but it should be displayed only when a Supervisor is logged in not when Executive logged in.
When I am hard coding visible to zero it is not displaying as follows:
[
'label' => 'Executive Name',
'attribute' => 'cs.first_name',
'visible' => '0',
],
But I want to display it conditionally something like this:
[
'label' => 'Executive Name',
'attribute' => 'cs.first_name',
'visible' => function ($data) {
if ($data->hc_customersupport->is_supervisor) {
return '1'; // or return true;
} else {
return '0'; // or return false;
}
},
],
Please tell if this approach is correct.