當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。