/** * Lists all Source models. * @return mixed */ public function actionIndex() { $params = Yii::$app->request->get(); $query = Source::find(); #$query->where(['status' => Basic::STATUS_NORMAL]); if (isset($params['basic_id'])) { $query->andWhere(['basic_id' => $params['basic_id']]); } $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $data = $query->offset($pages->offset)->limit($pages->limit)->asArray()->all(); if ($data) { foreach ($data as $key => $value) { $basicData = Basic::findOne($value['basic_id']); $data[$key]['title'] = $basicData->title; } } #echo "<pre>";print_r($data);exit; return $this->render('index', ['data' => $data, 'pages' => $pages, 'params' => $params]); }