示例#1
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->pagination->pageSize = 5;
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#2
0
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex()
 {
     Url::remember(Url::current(), 'books');
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#3
0
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     Url::remember();
     $dataProvider->sort->attributes['author_fullname'] = ['asc' => ['author.lastname' => SORT_ASC], 'desc' => ['author.lastname' => SORT_DESC]];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => Author::find()->all()]);
 }
示例#4
0
 public function actionIndex()
 {
     $model = new BookSearch();
     Url::remember('', 'returnUrl');
     //		var_dump(\Yii::$app->request->get());
     $dataProvider = $model->search(\Yii::$app->request->get());
     return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $model]);
 }
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $authors = Author::find()->all();
     $dropDownSearchItems = ArrayHelper::map($authors, 'id', 'lastname');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'dropDownSearchItems' => $dropDownSearchItems]);
 }
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     Yii::$app->session->setFlash('redirectUrl', Yii::$app->request->url);
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (!empty($id)) {
         $model = $this->findModel($id);
         return $this->render('index', ['bookModel' => $model, 'imageResponse' => Html::img(Url::toRoute($model->imageUrl), ['style' => 'width:550px;']), 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#7
0
 public function actionSearch()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $authorData = Author::find()->all();
     $authorsList = [];
     foreach ($authorData as $author) {
         $authorsList[$author->id] = $author->firstname . ' ' . $author->lastname;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => $authorsList]);
 }
示例#8
0
 public function actionIndex()
 {
     $get = Yii::$app->request->get();
     $formModel = new BookSearchForm();
     $formModel->load(Yii::$app->request->get());
     $searchModel = new BookSearch();
     // dirty hack to use form instead of built-in gridView filter
     if (isset($get[$formModel->formName()])) {
         $get[$searchModel->formName()] = $get[$formModel->formName()];
     }
     $dataProvider = $searchModel->search($get);
     Yii::$app->getUser()->setReturnUrl(Yii::$app->request->getUrl());
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'formModel' => $formModel]);
 }
 /**
  * Updates an existing Book model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $searchModel = new BookSearch();
     $authors = $searchModel->getAuthors()->all();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $url = Yii::$app->session->get('lastBookIndexUrl');
         if (!$url) {
             $url = "/";
         }
         return $this->redirect($url);
     } else {
         return $this->render('update', ['model' => $model, 'authors' => $authors]);
     }
 }
示例#10
0
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = null;
     if (!Yii::$app->user->isGuest) {
         $name = Yii::$app->user->identity->username;
         if ($name != 'admin') {
             $dataProvider = $searchModel->search([$searchModel->formName() => ['name' => $name]]);
         } else {
             $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         }
     } else {
         return $this->redirect(Yii::$app->homeUrl . '?r=site/login');
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#11
0
 /**
  * Lists all Books models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => Author::find()->all()]);
 }
示例#12
0
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new BookSearch();
     $dataProvider = $searchModel->search($this->getFilters());
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#13
0
 /**
  * Lists all Book models.
  * @return mixed
  */
 public function actionGetbooks()
 {
     $searchModel = new BookSearch();
     return $searchModel->search();
 }