/** * Update inventory item * GET /inventory/(item)/save * * @param Request $request * @param Inventory $item * * @return */ public function save(Request $request, Inventory $item) { $offset = count($request->category) - 1; /* * Set Category to NULL if requested category is 0 */ $category = $request->category[$offset]; if ($category == 0 && $offset < 1) { $category = NULL; } elseif ($category == 0) { $category = $request->category[$offset - 1]; } $item->serialnr = $request->serialnr; $item->name = $request->name; $item->brand_id = $request->brand_id; $item->category_id = $category; $item->save(); $item->saveDetails($request); $supplier = Supplier::find($request->supplier_id); return Picture::saveImages($item, $supplier, $request); //$item->updateBarcode($request->barcode); //return $item; }