示例#1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $product = Product::where('id', $id)->firstOrFail();
     // return Response::json(Input::all());
     $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::where('product_id', $product->id)->where('price_type_id', $type->id)->first();
         $prices->account_id = 1;
         //if(Input::get('price-'.$price->id))
         $price->cost = Input::get('price-' . $price->id);
         // else
         //   $price =$default_cost;
         $price->price_type_id = $type->id;
         $price->product_id = $product->id;
         $price->save();
     }
     Session::flash('message', "Producto actualizado con exito");
     return Redirect::to('productos');
 }
示例#2
0
 private static function getViewModel()
 {
     return ['branches' => Branch::where('account_id', '=', Auth::user()->account_id)->where('public_id', '>', 0)->orderBy('public_id')->get(), 'price_types' => PriceType::orderBy('id')->get(), 'allgroups' => Group::orderBy('id')->get(array('id', 'name'))];
 }