I am new to Yii Framework and need help from experts here…
So basically I have table which i want to pivot as follows:
So far i can only display the repeating user in one column, all dates in one column and values in another filtering data between given dates with following code in controller:
$dataProvider = new ActiveDataProvider([
'query' =>Model::find()
->Where(['between', 'date', $start_date, $end_date])
]);
and in view I have gridview widget as follows:
<?php
echo GridView::Widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'user_id' => [
'attribute' => 'user_id',
'label' => 'User Name',
'value' => function($model) {
return $model->user->name;
},
],
'date' => [
'label' => 'Date',
'format' => 'date',
'value' => 'date'
],
'value' =>[
'label' => 'hours',
'value' => 'value'
],
]
]);
?>
there any gridview logic where i can display dates as heading and respective value(hours) in cells corresponding to user id which is displayed in non-duplicate rows.
I would appreciate if someone can show me the Yii tricks here…thanks