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


PHP Product::save方法代码示例

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


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

示例1: store

 public function store(EditProductRequest $request)
 {
     $product = new Product();
     $product->fill($request->only($product->getFillable()));
     $product->save();
     return redirect()->route('product.index')->with('success_message', 'The product has been successfully saved.');
 }
开发者ID:rundef,项目名称:laravel_backbone,代码行数:7,代码来源: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()) {
         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

示例3: createItem

 /**
  *
  * @param $item
  */
 public function createItem($item)
 {
     $product = new Product();
     $product->name = $item['name'];
     $product->description = $item['description'];
     $product->price = $item['price'];
     $product->sell_price = $item['sell_price'];
     $product->created = date('Y-m-d H:i:s');
     $product->updated = date('Y-m-d H:i:s');
     $product->save();
     //update image after save product
     if (isset($item['image']) && $item['image'] !== 'undefined') {
         $this->updateImage($item['image'], $product->id);
     }
     //update description with image
     if (!empty($item['description'])) {
         $this->updateDescWithImg($item['description'], $product->id);
     }
     //add tags
     if (!empty($item['tags'])) {
         foreach ($item['tags'] as $k => $v) {
             $product->tag()->attach($v);
         }
     }
 }
开发者ID:kacana,项目名称:admin,代码行数:29,代码来源:Product.php

示例4: uploadMenuJson

 public function uploadMenuJson($restaurant_id)
 {
     $col0 = "col_0";
     $col1 = "col_1";
     $col2 = "col_2";
     $warehouse = null;
     $product = null;
     Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/web/upload/';
     $this->jsonFile = UploadedFile::getInstance($this, 'jsonFile');
     $this->jsonFile->saveAs(Yii::$app->params['uploadPath'] . $this->jsonFile->baseName . '.' . $this->jsonFile->extension);
     $json = json_decode(file_get_contents(Yii::$app->params['uploadPath'] . $this->jsonFile), true);
     $product_id = Product::find()->orderBy(['product_id' => SORT_DESC])->one()->product_id;
     $product_id++;
     foreach ($json as $array) {
         $warehouse = new Warehouse();
         $product = new Product();
         $product->name = $array[$col0];
         $product->description = $array[$col1];
         $product->save();
         $warehouse->restaurant_id = $restaurant_id;
         $warehouse->product_id = $product_id;
         $warehouse->price = $array[$col2];
         $warehouse->save();
         $product_id++;
     }
     return true;
 }
开发者ID:vodas,项目名称:praktykigda,代码行数:27,代码来源:FileUpload.php

示例5: postCreate

 public function postCreate()
 {
     $validator = Validator::make(Input::all(), Product::$rules);
     if ($validator->passes()) {
         $product = new Product();
         $product->name = Input::get('name');
         $product->category_id = Input::get('category_id');
         $product->short_description = Input::get('short_description');
         $product->long_description = Input::get('long_description');
         $product->is_discount = Input::get('is_discount');
         $product->discount = Input::get('discount');
         $product->count_for_discount = Input::get('count_for_discount');
         $product->is_default_discount = Input::get('is_default_discount');
         $product->default_discount = Input::get('default_discount');
         $product->price = Input::get('price');
         $product->amount = Input::get('amount');
         $product->yellow_qty = Input::get('yellow_qty');
         $product->red_qty = Input::get('red_qty');
         $product->code_1c = Input::get('code_1c');
         $product->article = Input::get('article');
         $product->availability = Input::get('availability');
         $product->save();
         return Redirect::to("admin/products/edit/{$product->id}")->with('message', "Продукт {$product->name} создан");
     }
     return Redirect::back()->with('message', 'Ошибка сохранения')->withErrors($validator)->withInput();
 }
开发者ID:venomir,项目名称:tc,代码行数:26,代码来源: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()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:index0h,项目名称:innovecs-test.pro,代码行数:15,代码来源:ProductController.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     $this->shared('product', function () {
         $product = new Product(["product_name" => "iPhone 6", "product_desc" => "iPhone 6", "status" => "available", "options" => [["name" => "颜色", "options" => ["深空灰", "银色", "金色"]], ["name" => "容量", "options" => ["16GB", "64GB", "128GB"]]], "specifications" => [["attr_name" => "高度", "attr_group" => "重量和尺寸", "attr_value" => "138.1 毫米(5.44 英寸)"], ["attr_name" => "宽度", "attr_group" => "重量和尺寸", "attr_value" => "67.0 毫米 (2.64 英寸)"], ["attr_name" => "厚度", "attr_group" => "重量和尺寸", "attr_value" => "6.9 毫米 (0.27 英寸)"], ["attr_name" => "重量", "attr_group" => "重量和尺寸", "attr_value" => "129 克 (4.55 盎司)"]]]);
         $product->save();
         return $product;
     });
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:9,代码来源:ProductStockTest.php

示例8: 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

示例9: 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

示例10: 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

示例11: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateProductRequest $request, Product $product)
 {
     $data = $request->input();
     $product->fill($data);
     $product->save();
     $this->savePhoto($product, $request);
     $product->categories()->detach($product->categories()->lists('id')->toArray());
     $product->categories()->attach($data['categories']);
     return Redirect()->route('home');
 }
开发者ID:RsanabriaZ,项目名称:web-catalog,代码行数:17,代码来源:ProductController.php

示例12: create_submit

 public function create_submit()
 {
     $product = new Product();
     $product->name = \Request::get('name');
     $product->desc = \Request::get('desc');
     $product->quantity = \Request::get('quantity');
     $product->user_id = \Auth::user()->id;
     $product->status = 'SALE';
     $product->save();
     return \Redirect()->action('ProductController@index');
 }
开发者ID:comsi02,项目名称:ordermart,代码行数:11,代码来源: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()
 {
     $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

示例14: fakeProduct

 protected function fakeProduct()
 {
     $fakeProduct = new Product();
     $fakeProduct->serial_number = "P1284724";
     $fakeProduct->primary_name = "Fake Product";
     $fakeProduct->product_type_id = $this->fakeProductType()->product_type_id;
     $fakeProduct->currency_id = $this->fakeCurrency()->currency_id;
     $fakeProduct->client_id = $this->fakeClient()->client_id;
     $fakeProduct->supplier_id = $this->fakeSupplier()->supplier_id;
     $fakeProduct->save();
     return $fakeProduct;
 }
开发者ID:boylee1111,项目名称:Reservation,代码行数:12,代码来源:DbTestCase.php

示例15: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $product = new Product();
     $product->name = $request->input('name');
     $product->price = $request->input('price');
     $product->description = $request->input('description');
     $product->save();
     for ($i = 0; $i < $request->input('stock'); $i++) {
         $item = new ProductItem();
         $item->code = date('YmdHis') . '.' . $i;
         $item = $product->item()->save($item);
     }
 }
开发者ID:ambarsetyawan,项目名称:laravel5-tokoonline,代码行数:18,代码来源:ProductController.php


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