/**
  * Lists all Country models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CountrySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     $this->render('index');
 }
 /**
  * Lists all Country models.
  * @return mixed
  */
 public function actionIndex()
 {
     yii::warning('yyy aaa ', __METHOD__);
     $searchModel = new CountrySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Lists all Country models.
  * @return mixed
  */
 public function actionIndex3()
 {
     $model = new Country();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $model = new Country();
         //reset model
     }
     $searchModel = new CountrySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = new Sort(['defaultOrder' => ['createtime' => 'desc']]);
     $dataProvider->pagination = new Pagination(['defaultPageSize' => 5]);
     return $this->render('index3', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'msg' => 'hello']);
 }
 public function actionActiveRecord()
 {
     $countryExists = Country::find()->where(['code' => 'PR'])->exists();
     if (!$countryExists) {
         $model = new Country();
         $model->name = 'Pery';
         $model->code = 'PR';
         if (!$model->save()) {
             var_dump($model->getErrors());
             return "Model not saved";
         }
     }
     $country = Country::findOne('UA');
     $countries = Country::findAll(['UA', 'GB']);
     $searchModel = new CountrySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Example #5
0
 /**
  * Updates an existing Country 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 CountrySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         $model->attributes = $_POST['Country'];
         $model->updated_by = Yii::$app->getid->getId();
         $model->updated_at = new \yii\db\Expression('NOW()');
         if ($model->save()) {
             return $this->redirect(['index']);
         } else {
             return $this->render('index', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
         }
     } else {
         return $this->render('index', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     }
 }
Example #6
0
 function actionIndex()
 {
     $countrySearch = new CountrySearch();
     $dataProvider = $countrySearch->search($_GET);
     return $this->render('index', ['dataProvider' => $dataProvider, 'countrySearch' => $countrySearch]);
 }