예제 #1
0
 public function update($id)
 {
     $priceType = PriceType::where('id', $id)->first();
     $priceType->name = Input::get('name');
     $priceType->save();
     $products = Product::get();
     //$default_cost=Input::get('price-1');
     //$type
     $prices = Price::where('price_type_id', $id)->get();
     foreach ($prices as $price) {
         $pri = Price::where('id', $price->id)->first();
         //if(Input::get('price-'.$pri->id))
         $price->cost = Input::get('price-' . $pri->id);
         //$price->price_type_id = $priceType->id;
         //$price->product_id = $product->id;
         $price->save();
     }
     Session::flash('message', "Precio actualizado con exito");
     return Redirect::to('precios');
 }
예제 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $product = Product::where('id', $id)->first();
     $prices = Price::where('product_id', $id)->orderBy('price_type_id', 'ASC')->get();
     $new_prices = array();
     foreach ($prices as $price) {
         $types = PriceType::where('id', $price->price_type_id)->first();
         $price->name = $types->name;
         array_push($new_prices, $price);
     }
     //$categories = Category::where('account_id',Auth::user()->account_id)->orderBy('id')->get();
     $data = ['product' => $product, 'method' => 'PUT', 'url' => 'productos/' . $id, 'title' => 'Editar Producto', 'precios' => $new_prices];
     return View::make('productos.edit', $data);
 }
예제 #3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     if (Auth::user()->is_admin) {
         $usuario = User::where('id', $id)->first();
         if ($usuario->is_admin == 1) {
             $rol = "Administrador";
         } else {
             $rol = "Facturador";
         }
         $price = PriceType::where('id', $usuario->price_type_id)->first();
         //print_r(explode(',', $usuario->group_ids));
         //return 0;
         $groups = Group::whereIn('id', explode(',', $usuario->group_ids))->get();
         $data = ['usuario' => $usuario, 'rol' => $rol, 'precio' => $price->name, 'grupos' => $groups];
         return View::make('users.show', $data);
     }
     return Redirect::to('/inicio');
 }