Exemplo n.º 1
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     //$mainCategory = new MainCategory();
     // $category = new Category();
     //Search
     $mainCategory = MainCategory::find()->all();
     $searchModel = new \common\models\search\GSearch();
     $dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
     return $this->render('index', ['maincategory' => $mainCategory, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemplo n.º 2
0
 public function actionClassified($id)
 {
     $modelCover = new Profile();
     $modelCover = $this->findModel($id);
     //Sort data
     $sort = new \yii\data\Sort(['attributes' => ['create_at' => ['asc' => ['create_at' => SORT_ASC], 'desc' => ['create_at' => SORT_DESC], 'default' => SORT_DESC]]]);
     //pagination
     $queryPage = Classified::find()->where(['user_id' => $id]);
     $countQueryPage = clone $queryPage;
     $pagination = new \yii\data\Pagination(['totalCount' => $countQueryPage->count(), 'pageSize' => 2]);
     //Search
     $mainCategory = \common\models\MainCategory::find()->all();
     $searchModel = new \common\models\search\GSearch();
     $dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
     //query model
     $query = new \yii\db\Query();
     $query->select(['classified.id', 'classified.title', 'classified.description', 'classified.price', 'classified.create_at', 'classified.type', 'classified.user_id', 'classified.is_status', 'main_category.main_category', 'category.category', 'country.country', 'region.region', 'city.city', 'user.username'])->from('classified')->join('JOIN', 'category', 'category.id = classified.category_id')->join('JOIN', 'main_category', 'main_category.id = classified.main_category_id')->join('JOIN', 'country', 'country.id = classified.country_id')->join('JOIN', 'region', 'region.id = classified.region_id')->join('JOIN', 'city', 'city.id = classified.city_id')->join('JOIN', 'user', 'user.id = classified.user_id')->where(['user_id' => $id])->offset($pagination->offset)->limit($pagination->limit)->orderBy($sort->orders)->all();
     $command = $query->createCommand();
     $data = $command->queryAll();
     return $this->render('classified', ['data' => $data, 'sort' => $sort, 'pagination' => $pagination, 'maincategory' => $mainCategory, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'modelCover' => $modelCover]);
 }
Exemplo n.º 3
0
 public function actionGsearch()
 {
     $searchModel = new \common\models\search\GSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('_gsearch', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }