当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::load方法代码示例

本文整理汇总了PHP中app\models\Country::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::load方法的具体用法?PHP Country::load怎么用?PHP Country::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Country的用法示例。


在下文中一共展示了Country::load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Создание контента
  * @return string
  */
 public function actionCreate()
 {
     $model = new Country();
     $uploadImg = new UploadForm();
     if (Yii::$app->request->isPost) {
         $uploadImg->img = UploadedFile::getInstance($uploadImg, 'img');
         if ($uploadImg->img && $uploadImg->validate()) {
             $uploadImg->img->saveAs('uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension);
         } else {
             print_r($uploadImg->getErrors());
         }
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->name = Yii::$app->request->post('Country')['name'];
         $model->iso_code = Yii::$app->request->post('Country')['iso_code'];
         $model->soc_abrev = Yii::$app->request->post('Country')['soc_abrev'];
         $model->soccer_code = Yii::$app->request->post('Country')['soccer_code'];
         if (isset($uploadImg->img)) {
             $model->icon = Url::base() . 'uploads/icoflags/' . Yii::$app->translater->translit($uploadImg->img->baseName) . '.' . $uploadImg->img->extension;
         }
         $model->save(false);
         return $this->redirect(Url::toRoute('countries/index'));
     } else {
         return $this->render('_form', ['model' => $model, 'uploadImg' => $uploadImg]);
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:30,代码来源:CountriesController.php

示例2: actionCreate

 /**
  * Creates a new Country model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Country();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->country_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:vab777,项目名称:marts.id_be,代码行数:14,代码来源:CountryController.php

示例3: actionUpdate

 /**
  * Updates an existing Country model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id = null)
 {
     if ($id) {
         $model = $this->findModel($id);
     } else {
         $model = new Country();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
         return $this->redirect(['index']);
     } else {
         return $this->renderAjax('update', ['model' => $model]);
     }
 }
开发者ID:vsguts,项目名称:crm,代码行数:20,代码来源:CountryController.php

示例4: getAll

 public static function getAll()
 {
     if (empty(self::$list)) {
         if ($file = file_get_contents(Yii::$app->basePath . '/web/data/countries.json')) {
             $list = Json::decode($file);
             if (!empty($list['countries'])) {
                 foreach ($list['countries'] as $data) {
                     $country = new Country();
                     $country->load(['Country' => $data]);
                     self::$list[$data['code']] = $country;
                 }
             }
         }
     }
     return self::$list;
 }
开发者ID:spinybeast,项目名称:lolipops,代码行数:16,代码来源:Country.php

示例5: actionCreate

 /**
  * Creates a new Country model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Country();
     $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->created_by = Yii::$app->getid->getId();
         $model->created_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]);
     }
 }
开发者ID:EduSec,项目名称:EduSec,代码行数:27,代码来源:CountryController.php


注:本文中的app\models\Country::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。