/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     Holiday::find($id)->update($request->all());
     flash()->success('Successfully Updated');
     return redirect('holiday');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $holiday = Holiday::find($id);
     if ($holiday) {
         $holiday->delete();
         flash()->success("Holiday successfully deleted.");
     }
 }
示例#3
0
 public function postDelete(Request $request)
 {
     //gets the holiday that the escape belongs to
     $holiday = \App\Holiday::find($request->holiday_id);
     //loads the escape to be delete
     $escapeToDelete = \App\Escape::find($request->id);
     //detaches the escape from the holiday
     $holiday->escapes()->detach($request->id);
     //deletes the escape
     $escapeToDelete->delete();
     //load the holiday with its escapes
     $holidayWithEscapes = \App\Holiday::with('escapes')->where('id', '=', $request->holiday_id)->get();
     return redirect('holiday/create');
 }
示例#4
0
 public function postUpdate(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:5', 'description' => 'required|min:5|max:256', 'due_date' => 'required|date']);
     //gets the holiday to be updated and loads the request data to the DB
     $holiday_to_update = \App\Holiday::where('id', '=', $request->id)->update(['name' => $request->name, 'description' => $request->description, 'due_date' => $request->due_date]);
     //retrieves the updated data from the db for display
     $holiday = \App\Holiday::find($request->id);
     return view('holidays.update')->with('holiday', $holiday);
 }