Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // Find the Purpose
     $purpose = Purpose::find($id);
     // Update data
     $purpose->label = $request->label;
     // Save it
     $purpose->save();
     session()->flash('message', 'Purpose has been saved');
     session()->flash('message-type', 'success');
     return redirect()->action('PurposeController@show', [$purpose->id]);
 }
Ejemplo n.º 2
0
 /**
  * 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]);
 }