/** * 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]); }
/** * 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]); }
/** * 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]); }
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); 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()]); }
/** * 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() { $searchModel = new BookSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $authors = $searchModel->getAuthors()->all(); Yii::$app->session->set('lastBookIndexUrl', Yii::$app->request->getUrl()); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'authors' => $authors]); }
/** * 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]); }
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]); }
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]); }
/** * 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()]); }
/** * 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]); }
/** * Lists all Book models. * @return mixed */ public function actionGetbooks() { $searchModel = new BookSearch(); return $searchModel->search(); }