Exemplo n.º 1
0
 public function getDelete($exerciseID)
 {
     $exercise = \App\Exercise::find($exerciseID);
     if ($exercise && $exercise->user_id == \Auth::User()->id) {
         $exercise->delete();
     }
     return redirect('/user/workouts/exercises');
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $id)
 {
     $exercise = Exercise::find($id);
     if ($exercise && ($exercise->user_id == $request->user()->id || $request->user()->is_admin())) {
         $exercise->delete();
         $data['message'] = 'Exercise deleted Successfully';
     } else {
         $data['errors'] = 'Invalid Operation. You have not sufficient permissions';
     }
     return redirect('/exercise/index')->with($data);
 }