/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $update = \App\Inventory::find($id); $product_id = $update->product_id; $update->update($request->except('_token')); return $product_id; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $inventory = Inventory::find($id); $inventory->delete(); Session::flash('flash_message', 'Successfully deleted!'); return redirect()->action('InvController@index'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $orderID, $id) { // create the new Order $inventory = Inventory::find($id); $order = Order::find($orderID); $bullet = Bullet::find($request->bullet_id); // Get the data $inventory->boxes = $request->boxes; $inventory->rounds_per_box = $request->rounds_per_box; $inventory->rounds = $request->rounds_per_box * $request->boxes; $inventory->cost_per_box = $request->cost_per_box; $inventory->cost = $request->cost_per_box * $request->boxes; $inventory->notes = $request->notes; // Make relationships $inventory->bullet()->associate($bullet); $inventory->order()->associate($order); // Update the totals $inventory->order->updateCost(); $inventory->order->updateRounds(); $inventory->order->save(); // Save the Order $inventory->save(); // Update inventory for all Bullets Bullet::updateInventory(); session()->flash('message', 'Inventory has been Saved'); session()->flash('message-type', 'success'); return redirect()->action('InventoryController@show', [$order->id, $inventory->id]); }
public function updateInventory($id) { $attributes = Input::all(); $inventory = Inventory::find($id); $result = $inventory->fill($attributes)->save(); if ($result) { return redirect()->action('HomeController@getInventory'); } }