search(Yii::$app->request->queryParams); $reports = $dataProvider->getModels(); $reports_array = array_column($reports, 'attributes'); foreach ($reports as $i => $report){ $reports_array[$i]['today'] = array_column($report->task, 'attributes'); } $response = Yii::$app->response; $response->format = Response::FORMAT_JSON; $response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8'); $response->content = json_encode(array_merge( ['reports' => $reports_array], ['month' => (array)new Month($year.'-'.$month.'-01')]) ); return $response; } }