/** * Lists all Books models. * @return mixed */ public function actionIndex() { $session = Yii::$app->session; $session->open(); $searchModel = new BooksSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $searchAuthModel = new AuthorsSearch(); $authors = $searchAuthModel->getAuthors(); Yii::$app->session['dataProvider'] = $dataProvider; Yii::$app->session['searchModel'] = $searchModel; Yii::$app->session['authors'] = $authors; if (!\Yii::$app->user->isGuest) { return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => $authors]); } else { return $this->goHome(); } // Если не авторизован, то отправить на форму авторизации }
/** * Lists all Authors models. * @return mixed */ public function actionIndex() { $searchModel = new AuthorsSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }