/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $tripID, $id) { // create the new Order $shoot = Shoot::find($id); $trip = Trip::find($tripID); $bullet = Bullet::find($request->bullet_id); // Get the data $shoot->rounds = $request->rounds; $shoot->firearm_id = $request->firearm_id; $shoot->notes = $request->notes; $shoot->trip()->associate($trip); $shoot->bullet()->associate($bullet); // Save the Order $shoot->save(); // Update inventory for all Bullets Bullet::updateInventory(); session()->flash('message', 'Shoot has been Saved'); session()->flash('message-type', 'success'); return redirect()->action('ShootController@show', [$trip->id, $shoot->id]); }
/** * 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]); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $cartridge_id, $id) { // Get models $bullet = Bullet::find($id); $cartridge = Cartridge::find($cartridge_id); $purpose = Purpose::find($request->purpose_id); // Update data $bullet->manufacturer = $request->manufacturer; $bullet->model = $request->model; $bullet->weight = $request->weight; $bullet->notes = $request->notes; // Update relationships $bullet->purpose()->associate($purpose); $bullet->cartridge()->associate($cartridge); // Save it $bullet->save(); session()->flash('message', 'Bullet has been saved'); session()->flash('message-type', 'success'); return redirect()->action('BulletController@show', [$cartridge->id, $bullet->id]); }