I am trying to access a variable on view file into Gridview
but it is throwing error that it should be array but null given
i am declaring $totalDays
on top of my view file and i am using it in Gridview
like below
[
'attribute' => 'class_id',
'format' => 'raw',
'label' => "Class Date",
'value' => function ($model) {
array_push($totalDays,$model->class->date);
return $model->class->date;
},
'footer'=> '<span>Total Days</span>',
],
But it throws following error
array_push() expects parameter 1 to be array, null given