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


PHP Price::createNew方法代码示例

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


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

示例1: store

 public function store()
 {
     $priceType = PriceType::createNew();
     $priceType->name = Input::get('name');
     $priceType->save();
     $products = Product::get();
     $default_cost = Input::get('price-1');
     foreach ($products as $product) {
         $price = Price::createNew();
         $price->account_id = 1;
         //if(Input::get('price-'.$product->id))
         $price->cost = Input::get('price-' . $priceType->id);
         //else
         // $price =$default_cost;
         $price->price_type_id = $priceType->id;
         $price->product_id = $product->id;
         $price->save();
     }
     Session::flash('message', "Precio creado con exito");
     return Redirect::to('precios');
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:21,代码来源:PriceController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // return Response::json(Input::all());
     //print_r(Input::all());
     //return 0;
     $product = Product::createNew();
     $product->setProductKey(trim(Input::get('product_key')));
     $product->setNotes(trim(Input::get('notes')));
     $product->setUnits(Input::get('units'));
     $product->setCc(Input::get('volume'));
     $product->setPackTypes(Input::get('type'));
     $product->setIce(Input::get('ice'));
     $typePrices = PriceType::orderBy('id', 'ASC')->get();
     $default_cost = Input::get('price-1');
     $product->save();
     foreach ($typePrices as $type) {
         $price = Price::createNew();
         $prices->account_id = 1;
         //if(Input::get('price-'.$type->id))
         $price->cost = Input::get('price-' . $type->id);
         //else
         //  $price =$default_cost;
         $price->price_type_id = $type->id;
         $price->product_id = $product->id;
         $price->save();
     }
     Session::flash('message', "Producto creado con exito");
     return Redirect::to('productos');
     //$product -> setCost(trim(Input::get('cost')));
     //$product -> setQty(trim(Input::get('qty')));
     //$product -> setCategory(trim(Input::get('category_id')));
     $error = $product->guardar();
     if (Input::get('json') == "1") {
         if ($error) {
             return json_encode($error);
         }
         $product->setIsProduct(1);
         $product->save();
         return json_encode(0);
     }
     if (Input::get('json') == "2") {
         if ($error) {
             return json_encode($error);
         }
         //$resultado = $product->guardar();
         $product->setIsProduct(0);
         $product->save();
         return json_encode(0);
     }
     //$product->is_product =trim(Input::get('is_product'));
     //$product->unidad_id =trim(Input::get('unidad_id'));
     //$product -> setPublicId(trim(Input::get('')));
     //$product->setAccount(trim(Input::get('')));
     //$product->setUser(trim(Input::get('')));
     $resultado = $product->guardar();
     if (!$resultado) {
         $message = $product->is_product ? "Producto creado con éxito" : "Servicio creado con éxito";
         $product->save();
     } else {
         $url = 'productos/create';
         Session::flash('error', $resultado);
         return Redirect::to($url)->withInput();
     }
     // $product ->	product_key =	;
     // $product ->	notes		=	trim(Input::get('notes'));
     // $product -> cost 		=	trim(Input::get(''));
     // $product ->	category_id =	trim(Input::get('category_id'));
     // $product ->	save();
     //if(null!=Input::get('json'));
     //		return Response::json(array());
     Session::flash('message', $message);
     return Redirect::to('productos');
 }
开发者ID:Vrian7ipx,项目名称:repocas,代码行数:78,代码来源:ProductController.php

示例3: save

 private function save($publicId = null)
 {
     if ($publicId) {
         $product = Product::scope($publicId)->firstOrFail();
     } else {
         $product = Product::createNew();
     }
     $product->product_key = trim(Input::get('product_key'));
     $product->notes = trim(Input::get('notes'));
     $product->pack_types = trim(Input::get('pack_types'));
     $product->ice = trim(Input::get('ice'));
     $product->units = trim(Input::get('units'));
     $product->cc = trim(Input::get('cc'));
     $product->save();
     $data = json_decode(Input::get('data'));
     $pricesIds = [];
     $id = 1;
     foreach ($data->prices as $price) {
         if (isset($price->public_id) && $price->public_id) {
             $record = Price::scope($price->public_id)->firstOrFail();
         } else {
             $record = Price::createNew();
         }
         $record->price_type_id = $id;
         $record->cost = trim($price->cost);
         $product->prices()->save($record);
         $priceIds[] = $record->public_id;
         $id++;
     }
     foreach ($product->prices as $price) {
         if (!in_array($price->public_id, $priceIds)) {
             $price->delete();
         }
     }
     if ($publicId) {
         Session::flash('message', trans('texts.updated_product'));
     } else {
         // Activity::createProduct($product);
         Session::flash('message', trans('texts.created_product'));
     }
     return Redirect::to('products/' . $product->public_id);
 }
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:42,代码来源:ProductController.php


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