/**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // Сохраним (или загрузим) в сессии параметры фильтров и сортировки
     if (Yii::$app->request->queryParams || Yii::$app->request->get('sort')) {
         Yii::$app->session->set('BookSearchUrl', Yii::$app->request->url);
     } else {
         if ($url = Yii::$app->session->get('BookSearchUrl')) {
             $this->redirect($url);
         }
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BooksSearch();
     $model = new Books();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //$author = Authors::find()->where(['id' => $model->id])->one();
     //echo $author = $author->lastname." ".$author->firstname;die();
     // id автора
     //$book = Books::find()->where(['id' => $id])->one();
     //$author_id = $book->author_id;
     // ФИО автора по id
     //$author = Authors::find()->where(['id' => $author_id])->one();
     //$author = $author->lastname." ".$author->firstname;
     return $this->render('index', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Beispiel #3
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     //        $searchModel = new BooksSearch();
     //        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //
     //        return $this->render('index', [
     //            'searchModel' => $searchModel,
     //            'dataProvider' => $dataProvider,
     //        ]);
     $searchModel = new BooksSearch();
     if (Yii::$app->request->queryParams) {
         $books = $searchModel->search(Yii::$app->request->queryParams);
     } else {
         $books = $searchModel->getAllBooks();
     }
     return $this->render('index', ['searchModel' => $searchModel, 'books' => $books]);
 }