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


PHP Category::load方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Category model.
  * For ajax request will return json object
  * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $request = Yii::$app->request;
     $model = new Category();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Create new Category", 'content' => $this->renderAjax('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => '#crud-datatable-pjax', 'title' => "Create new Category", 'content' => '<span class="text-success">Create Category success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Create new Category", 'content' => $this->renderAjax('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }
开发者ID:javierojeda94,项目名称:sas_final,代码行数:35,代码来源:CategoryController.php

示例2: actionCreate

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

示例3: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', "Category <strong>{$model->title}</strong> created.");
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:shahid80,项目名称:EWay,代码行数:15,代码来源:CategoriesController.php

示例4: actionCreate

 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list']);
     } else {
         $model->status = Category::STATUS_ENABLED;
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:phucnv206,项目名称:thoitrang,代码行数:10,代码来源:CategoryController.php

示例5: actionCreate

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

示例6: actionNew

 public function actionNew()
 {
     $categoryModel = new Category();
     $message = '';
     if (!empty(Yii::$app->request->post('Category'))) {
         if ($categoryModel->load(Yii::$app->request->post()) && $categoryModel->save()) {
             $message = 'Category added success';
         }
     }
     return $this->render('new', ['model' => $categoryModel, 'message' => $message]);
 }
开发者ID:stanislavdev1993,项目名称:blog,代码行数:11,代码来源:CategoryController.php

示例7: actionCreate

 public function actionCreate()
 {
     $model = new Category();
     $model->user_id = Yii::$app->user->identity->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash("Category-success", Yii::t("app", "Category successfully included"));
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:BakhtiyorRuziev,项目名称:economizzer,代码行数:11,代码来源:CategoryController.php

示例8: actionCreate

 /**
  * Creates a new Category model.
  */
 public function actionCreate()
 {
     $model = new Category();
     $model->scenario = 'insert';
     if ($model->load(Yii::$app->request->post())) {
         MyModel::upload($model);
         if ($model->save() && MyModel::updateParents($model)) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
         return $this->render('create', ['model' => $model]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:ClarkLusm,项目名称:htdocs,代码行数:17,代码来源:CategoryController.php

示例9: actionCreate

 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->parent == 0) {
             $model->saveNode();
         } elseif ($model->parent) {
             $root = Category::find($model->parent);
             $model->appendTo($root);
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:brownshang,项目名称:yii2-nested-set-behavior,代码行数:15,代码来源:CategoryController.php

示例10: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->parent == 0) {
             $model->saveNode();
         } else {
             if ($model->parent) {
                 $root = $this->findModel($model->parent);
                 $model->appendTo($root);
             }
         }
         return $this->render('tree');
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:GHubgenius,项目名称:dcms,代码行数:22,代码来源:CategoryController.php

示例11: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('categoryCreate')) {
         $model = new Category();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         if (Yii::$app->user->isGuest) {
             Yii::$app->user->loginRequired();
         } else {
             throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
         }
     }
 }
开发者ID:pyw5pkU9PcdW,项目名称:COMP3421,代码行数:22,代码来源:CategoryController.php

示例12: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can("category/create")) {
         $model = new Category();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             if ($model->parent == NULL) {
                 $model->parent = 0;
                 $model->save();
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         Yii::$app->session->setFlash('error', 'Нет доступа!');
         $this->redirect('/');
     }
 }
开发者ID:dosh93,项目名称:shop,代码行数:23,代码来源:CategoryController.php

示例13: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     $category_array = Category::getAllCategories();
     if ($category_array) {
         $category_array = ['0' => '顶级分类'] + $category_array;
     } else {
         $category_array = ['0' => '顶级分类'];
     }
     if (isset($category_array[1]) && $category_array[1] == '未分类') {
         unset($category_array[1]);
     }
     if ($model->load($_POST)) {
         if ($model->save()) {
             $this->redirect(['category/view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model, 'category_array' => $category_array]);
 }
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:24,代码来源:CategoryController.php

示例14: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post())) {
         $model->url = UrlHelp::translateUrl($model->name);
         if ($model->validate()) {
             $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
             if ($model->imageFile) {
                 if ($imgName = $model->upload($model->url)) {
                     $model->img = $imgName;
                 }
             }
             $model->imageFile = null;
             $model->save();
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:comaw,项目名称:hashtag,代码行数:24,代码来源:CategoryController.php

示例15: actionCreate

 /**
  * Creates a new Category model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Category();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (isset($_POST['name']) && is_array($_POST['name'])) {
             foreach ($_POST['name'] as $lang => $val) {
                 $model->setName($lang, $val);
             }
         }
         if (isset($_POST['content']) && is_array($_POST['content'])) {
             foreach ($_POST['content'] as $lang => $val) {
                 $model->setContent($lang, $val);
             }
         }
         $model->updateURLCode();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:rcjusto,项目名称:simplestore,代码行数:25,代码来源:CategoryController.php


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