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


PHP Product::load方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     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['description']) && is_array($_POST['description'])) {
             foreach ($_POST['description'] as $lang => $val) {
                 $model->setDescription($lang, $val);
             }
         }
         if (isset($_POST['information']) && is_array($_POST['information'])) {
             foreach ($_POST['information'] as $lang => $val) {
                 $model->setInformation($lang, $val);
             }
         }
         $model->updateURLCode();
         return $this->redirect(['update', 'id' => $model->id, 'panel' => 'images']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:rcjusto,项目名称:simplestore,代码行数:30,代码来源:ProductController.php

示例2: actionCreate

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

示例3: actionCreateProduct

 /**
  * Pjaxified version of ProductController actionCreate
  * @return partial
  */
 public function actionCreateProduct()
 {
     $model = new Product();
     if (Yii::$app->request->isPjax) {
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             $model = new Product();
         }
         return $this->renderPartial('_product_edit', ['model' => $model]);
     }
 }
开发者ID:secondsano,项目名称:mebel,代码行数:14,代码来源:AdminController.php

示例4: actionCreate

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

示例5: actionCreate

 /**
  * @param $node
  * @return string|\yii\web\Response
  */
 public function actionCreate($node)
 {
     $model = new Product();
     $model->loadDefaultValues();
     $model->category_id = $node;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['list', 'node' => $node]);
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:vetoni,项目名称:toko,代码行数:14,代码来源:ProductController.php

示例6: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(Yii::$app->request->post())) {
         // var_dump($_POST);
         $this->isUploaded($model);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:irying,项目名称:artist,代码行数:15,代码来源:ProductController.php

示例7: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $categories = Categories::find()->all();
     // need this for dropDownList in views/product/_form.php
     $model = new Product();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'itemId' => $model->item_id]);
     } else {
         return $this->render('create', ['model' => $model, 'categories' => $categories]);
     }
 }
开发者ID:asopin,项目名称:shop,代码行数:16,代码来源:ProductController.php

示例8: actionSearchProducts

 public function actionSearchProducts()
 {
     $modelForm = new Product();
     $results = null;
     if ($modelForm->load(Yii::$app->request->post())) {
         $results = $modelForm->giveAllProductsByName($modelForm->name);
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
     } else {
         return $this->render('searchProducts', ['modelForm' => $modelForm, 'results' => $results]);
     }
 }
开发者ID:vodas,项目名称:praktykirepofinito,代码行数:12,代码来源:SiteController.php

示例9: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $app = \Yii::$app;
     $model = new Product();
     $render = "render";
     if ($app->request->isPjax || $app->request->isAjax) {
         $render = "renderPartial";
     }
     if ($model->load($app->request->post()) && $model->save()) {
         $model = new Product();
     }
     return $this->{$render}('form', ['model' => $model]);
 }
开发者ID:secondsano,项目名称:mebel,代码行数:18,代码来源:ProductController.php

示例10: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(Yii::$app->request->post())) {
         $model->created_time = date("Y-m-d H:i:s");
         $model->last_update = $model->created_time;
         $model->user_id = \Yii::$app->user->id;
         Util::save($model);
         $model = new Product();
     }
     $searchModel = new ProductSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('create', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
开发者ID:adsavin,项目名称:car,代码行数:19,代码来源:ProductController.php

示例11: store

 public function store(Request $request)
 {
     $input = $request->json()->all();
     unset($input['categories']);
     $product = new Product($input);
     $product->save();
     if (($categories = $request->json()->get('categories')) && !empty($categories)) {
         if (is_string($categories)) {
             $categories = explode(',', $categories);
         }
         $product->categories()->attach($categories);
     }
     $product->load('categories');
     return response()->created($product);
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:15,代码来源:ProductController.php

示例12: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     $model_can_save = false;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $model->fileImage = \yii\web\UploadedFile::getInstance($model, 'fileImage');
         if ($model->fileImage) {
             $model->fileImage->saveAs(Yii::getAlias('@uploadedfilesdir'));
         }
         $model_can_save = true;
         return $this->redirect(['view', 'id' => $model->product_id]);
     } else {
         return $this->render('create', ['model' => $model, 'model_can_save' => $model_can_save]);
     }
 }
开发者ID:khuebt,项目名称:gem,代码行数:20,代码来源:ProductController.php

示例13: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post())) {
         $model->images = UploadedFile::getInstances($model, images);
         $model->image = FileUploader::upload(UploadedFile::getInstance($model, 'image'), 'product', $model->image);
         if ($model->validate()) {
             if ($model->save()) {
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:happyhaha,项目名称:helpers,代码行数:20,代码来源:ProductController.php

示例14: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Product();
     $model->scenario = 'create';
     if ($model->load(Yii::$app->request->post())) {
         $image1 = UploadedFile::getInstance($model, 'image1');
         if ($image1 != NULL) {
             $name1 = date('Y_m_d_H_i_s_') . $image1->baseName . '.' . $image1->extension;
             $model->image1 = $name1;
         }
         $image2 = UploadedFile::getInstance($model, 'image2');
         if ($image2 != NULL) {
             $name2 = date('Y_m_d_H_i_s_') . $image2->baseName . '.' . $image2->extension;
             $model->image2 = $name2;
         }
         $image3 = UploadedFile::getInstance($model, 'image3');
         if ($image3 != NULL) {
             $name3 = date('Y_m_d_H_i_s_') . $image3->baseName . '.' . $image3->extension;
             $model->image3 = $name3;
         }
         if ($model->save()) {
             if ($model->auction == "YES") {
                 $auction = new Auction();
                 $auction->product_id = $model->id;
                 $auction->value = $model->price;
                 $auction->save();
             }
             if ($image1 != NULL) {
                 $image1->saveAs('img/products/' . $name1);
             }
             if ($image2 != NULL) {
                 $image2->saveAs('img/products/' . $name2);
             }
             if ($image3 != NULL) {
                 $image3->saveAs('img/products/' . $name3);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:frankpaul142,项目名称:mosaico,代码行数:49,代码来源:ProductController.php

示例15: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $this->checkLogin();
     $this->layout = 'admin';
     $model = new Product();
     $modelType = new Type();
     $allType = $modelType->getAllType();
     if ($model->load(Yii::$app->request->post())) {
         $model->image = UploadedFile::getInstances($model, 'image');
         foreach ($model->image as $file) {
             $file->saveAs('images/' . $file->baseName . '.' . $file->extension);
             $images[] = $file->baseName . '.' . $file->extension;
         }
         $model->image = implode(',', $images);
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'allType' => $allType]);
     }
 }
开发者ID:royutoan,项目名称:pianodanang,代码行数:25,代码来源:ProductController.php


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