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


PHP Product::load方法代码示例

本文整理汇总了PHP中common\models\Product::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::load方法的具体用法?PHP Product::load怎么用?PHP Product::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\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(['scenario' => 'create']);
     $model->date = date('Y-m-d H:i');
     if ($model->load(Yii::$app->request->post())) {
         $model->image = UploadedFile::getInstance($model, 'image');
         $model->images = UploadedFile::getInstances($model, 'images');
         if ($model->validate() && $model->save() && $model->image) {
             // Working directory
             $dir = Yii::getAlias('@frontend/web/uploads/product/' . $model->id);
             FileHelper::createDirectory($dir);
             // Save main image
             $model->image->saveAs($dir . '/main.jpg');
             // Save images
             if ($model->images) {
                 foreach ($model->images as $image) {
                     $imageModel = new Image();
                     $imageModel->model_id = $model->id;
                     $imageModel->save();
                     $image->saveAs($dir . '/' . $imageModel->id . '.jpg');
                 }
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:cyanofresh,项目名称:yii2shop,代码行数:32,代码来源: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:fnoorman,项目名称:dev,代码行数:14,代码来源:ProductController.php

示例3: 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()) {
         Yii::$app->session->setFlash('success', 'Товар успешно создан!');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:ewrgergrgr,项目名称:nazar,代码行数:15,代码来源:ProductController.php

示例4: actionCreate

 public function actionCreate()
 {
     $model = new Product();
     if ($model->load(\Yii::$app->request->post())) {
         if ($model->validate() && $model->save()) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('form', ['model' => $model]);
 }
开发者ID:afernandes465,项目名称:fafediesel,代码行数:10,代码来源:ProductController.php

示例5: 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 = Category::find()->all();
     $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, 'categories' => $categories]);
     }
 }
开发者ID:Krinnerion,项目名称:shop,代码行数:15,代码来源: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();
     $categoryModel = new CategoryProduct();
     $treeParents = TreeHelper::build($categoryModel->find()->addOrderBy('tree')->addOrderBy('lft')->all());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'treeParents' => $treeParents]);
     }
 }
开发者ID:nguyentuansieu,项目名称:OneCMS,代码行数:16,代码来源:ProductController.php

示例7: insert

 public function insert(ProductDto $productDto)
 {
     $product = new Product();
     if ($product->load(['Product' => ArrayHelper::toArray($productDto)])) {
         $product->type = ArrayUtil::arrayToInt($productDto->type);
         $product->save();
         return ArrayHelper::toArray($product);
     } else {
         return [];
     }
 }
开发者ID:xiaomige,项目名称:giishop,代码行数:11,代码来源:ProductServiceImpl.php

示例8: actionCreate

 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $currUser = Yii::$app->user->getIdentity();
     $currMb = MerchantBrand::find()->where(['merchant_brand_id' => $currUser->username])->one();
     $mbFk = $currMb->_id;
     $model = new Product();
     $model->merchant_brand_fk = $mbFk;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => (string) $model->_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:chimgrrl,项目名称:auction,代码行数:18,代码来源:ProductController.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()
 {
     //if(!Yii::$app->user->can('createYourAuth')) throw new ForbiddenHttpException(Yii::t('app', 'No Auth'));
     $model = new Product();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         $model->type = ProductType::arrayToInt($model->type);
         if ($model->save()) {
             return $this->redirect(['update', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:liangdabiao,项目名称:funshop,代码行数: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 (!is_numeric($model['agreement_id'])) {
         $agreement = Agreement::find()->where(["default_flag" => 1])->asArray()->one();
         $model['agreement_id'] = $agreement['id'];
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $redirect = yii::$app->request->post('goto') == 'list' ? ['index'] : ['update', 'id' => $model->id];
         return $this->redirect($redirect);
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:kibercoder,项目名称:bilious-octo-fibula,代码行数:18,代码来源:ProductController.php

示例11: 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();
     $categoryModel = new ProductCategory();
     $companyModel = new ProductCompany();
     $treeParents = TreeHelper::build($categoryModel->find()->addOrderBy('tree')->addOrderBy('lft')->all());
     $treeCompany = ArrayHelper::map($companyModel->findAll(['status' => 10]), 'id', 'title');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'treeParents' => $treeParents, 'treeCompany' => $treeCompany]);
     }
 }
开发者ID:nguyentuansieu,项目名称:BioMedia,代码行数:18,代码来源:ProductController.php

示例12: actionProducts

 /**
  * Экшен '/admin/catalog/products' - список товаров
  * @return string
  * @throws InvalidParamException
  */
 public function actionProducts()
 {
     $filterModel = new Product();
     $filterModel->scenario = 'search';
     $filterModel->load(Yii::$app->request->get());
     $dataProvider = $filterModel->search();
     if ($filterModel->parents === 0) {
         $category = new Category();
         $category->title = 'Все товары';
     } else {
         $category = Category::findOne($filterModel->parents);
     }
     return $this->render('products', ['category' => $category, 'dataProvider' => $dataProvider, 'filterModel' => $filterModel]);
 }
开发者ID:andreykluev,项目名称:yii2-catalog-module,代码行数:19,代码来源:AdminController.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();
     if ($model->load(Yii::$app->request->post())) {
         $imageName = $model->product_name;
         $path = Yii::getAlias('@common') . '/web/uploads/';
         $model->file = UploadedFile::getInstance($model, 'file');
         $model->file->saveAs($path . $imageName . '.' . $model->file->extension);
         $model->product_main_picture = $path . $imageName . '.' . $model->file->extension;
         $model->admin_id = Yii::$app->user->getId();
         $model->product_created_date = date('Y-m-d');
         $model->save();
         return $this->redirect(['view', 'id' => $model->product_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:akiu,项目名称:first-yii,代码行数:22,代码来源: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();
     $parents = [];
     $root = Category::findOne(['parent_id' => null, 'title' => 'product', 'module' => 'product']);
     if (empty($root)) {
         throw new NotFoundHttpException('Module không tồn tại');
     }
     $parents = $root->children()->all();
     $parent_id = $this->buildTree($parents);
     if ($model->load(Yii::$app->request->post())) {
         $model['slug'] = $this->slugAlias($model);
         if ($model->save()) {
             return $this->redirect(['index']);
         }
     } else {
         return $this->render('create', ['model' => $model, 'parent_id' => $parent_id, 'statestock' => $this->getStateStock(), 'hotline' => $this->getHotline(), 'state' => $this->getStatus()]);
     }
 }
开发者ID:nguyentuansieu,项目名称:phutungoto,代码行数:24,代码来源:ProductController.php

示例15: actionCreate

 /**
  * Creates a new EntpProduct 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->loadDefaultValues();
         $model->save();
         if ($model->save()) {
             $produk = new EntpProduct();
             $produk->product_id = $this->id;
             $produk->entrepreneur_user_id = Yii::$app->user->id;
             $produk->link('product', $model);
         }
         Yii::$app->session->setFlash('success', 'Create New Product Success');
         return $this->redirect(['index']);
         //return $this->redirect(['view', 'entrepreneur_id' => $model->entrepreneur_id, 'product_id' => $model->product_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:azruljamil,项目名称:smev3,代码行数:24,代码来源:EntpproductController.php


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