/** * Remove the specified resource from storage. * * @param \App\Exercise $exercise * @param \App\Translation $translation * * @return \Illuminate\Http\Response */ public function destroy(Exercise $exercise, Translation $translation) { if (count($exercise->translations) > 1) { if ($exercise->translations()->find($translation->id)) { $exercise->translations()->detach($translation); $response = response('This translation has deleted.'); } else { $response = response()->json(['errors' => ['This translation hasn\'t found in the exercise word.']], 404); } } else { $response = response()->json(['errors' => ['Exercise can\'t exist without translations.']], 400); } return $response; }
public function addExercises($exercises) { foreach ($exercises as $exercise) { $exercise_id = Exercise::where('name', $exercise[0])->first(); $this->exercises()->attach($exercise_id, ['position' => $exercise[1]]); } }
public function getDelete($exerciseID) { $exercise = \App\Exercise::find($exerciseID); if ($exercise && $exercise->user_id == \Auth::User()->id) { $exercise->delete(); } return redirect('/user/workouts/exercises'); }
public function createExercise() { $users = User::all(); $words = Word::all(); foreach (range(1, 5) as $i) { $user = $users->random(); $word = $words->random(); $translation = $word->translations->random(); $exercise = new Exercise(); $exercise->status = 'new'; $exercise->reading = 10; $exercise->memory = 10; $exercise->user()->associate($user); $exercise->word()->associate($word); $exercise->translation()->associate($translation); $exercise->save(); echo 'Exercise id: ' . $exercise->id . '<br>'; } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // $this->call(UserTableSeeder::class); Model::reguard(); $userTest = User::create(['name' => 'userTest', 'email' => '*****@*****.**', 'password' => bcrypt('userTest'), 'height_inches' => 70]); $workout1 = Workout::create(['user_id' => $userTest->id, 'title' => 'Push', 'note' => 'This is a note']); $workout2 = Workout::create(['user_id' => $userTest->id, 'title' => 'Pull', 'note' => 'This is a note']); $workout3 = Workout::create(['user_id' => $userTest->id, 'title' => 'Legs', 'note' => 'This is a note']); $exercise1 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Barbell Bench Press', 'max_one_rep_max' => 190, 'type' => 'Weighted', 'category' => 'Chest']); $exercise2 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Overhead Press', 'max_one_rep_max' => 100, 'type' => 'Weighted', 'category' => 'Shoulders']); $exercise3 = Exercise::create(['user_id' => $userTest->id, 'title' => 'One Arm Row', 'max_one_rep_max' => 75, 'type' => 'Weighted', 'category' => 'Back']); $exercise4 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Pulldown', 'max_one_rep_max' => 200, 'type' => 'Weighted', 'category' => 'Back']); $exercise5 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Squats', 'max_one_rep_max' => 225, 'type' => 'Weighted', 'category' => 'Legs']); $exercise6 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Deadlifts', 'max_one_rep_max' => 200, 'type' => 'Weighted', 'category' => 'Legs']); $session1 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise1->id, 'session_date' => Carbon::now()]); $session2 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise2->id, 'session_date' => Carbon::now()]); $session3 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise3->id, 'session_date' => Carbon::now()]); $session4 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise4->id, 'session_date' => Carbon::now()]); $session5 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise5->id, 'session_date' => Carbon::now()]); $session6 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise6->id, 'session_date' => Carbon::now()]); $sessionSet1 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet2 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet3 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet4 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]); $sessionSet5 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]); $sessionSet6 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]); $sessionSet7 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]); $sessionSet8 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]); $sessionSet9 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]); $sessionSet10 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet11 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet12 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet13 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet14 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet15 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet16 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet17 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $sessionSet18 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]); $plan1 = Plan::create(['user_id' => $userTest->id, 'title' => '5/3/1', 'start_date' => Carbon::now(), 'end_date' => Carbon::now()->addWeeks(4)]); $planWorkout1 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout1->id]); $planWorkout2 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout2->id]); $planWorkout3 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout3->id]); $planDate1 = PlanDate::create(['plan_workout_id' => $planWorkout1->id, 'planned_date' => Carbon::tomorrow()]); $planDate2 = PlanDate::create(['plan_workout_id' => $planWorkout1->id, 'planned_date' => Carbon::tomorrow()->addDays(5)]); $planDate3 = PlanDate::create(['plan_workout_id' => $planWorkout2->id, 'planned_date' => Carbon::tomorrow()->addDay()]); $planDate4 = PlanDate::create(['plan_workout_id' => $planWorkout2->id, 'planned_date' => Carbon::tomorrow()->addDays(6)]); $planExercise1 = PlanExercise::create(['plan_workout_id' => $planWorkout1->id, 'exercise_id' => $exercise1->id, 'weight_to_add_for_success' => 5, 'weight_to_sub_for_fail' => 5]); $planExercise2 = PlanExercise::create(['plan_workout_id' => $planWorkout1->id, 'exercise_id' => $exercise2->id, 'weight_to_add_for_success' => 5, 'weight_to_sub_for_fail' => 5]); $planSet1 = PlanSet::create(['plan_exercise_id' => $planExercise1->id, 'expected_reps' => 10, 'expected_weight' => 100]); $planSet2 = PlanSet::create(['plan_exercise_id' => $planExercise1->id, 'expected_reps' => 10, 'expected_weight' => 100]); }
/** * Execute the console command. * * @return mixed */ public function handle() { DB::enableQueryLog(); // Delete all data in the database, TODO: remove before production DB::statement("SET foreign_key_checks=0"); ExerciseAlias::truncate(); DB::statement("TRUNCATE TABLE `exercise_aliases`"); DB::statement("SET foreign_key_checks=1"); $exercise_id = Exercise::where('name', 'Bicep curl')->first()->id; ExerciseAlias::create(['name' => 'Curls', 'exercise_id' => $exercise_id]); $exercise_id = Exercise::where('name', 'Skull-crusher')->first()->id; ExerciseAlias::create(['name' => 'Triceps extension', 'exercise_id' => $exercise_id]); $exercise_id = Exercise::where('name', 'Overhead press')->first()->id; ExerciseAlias::create(['name' => 'Military press', 'exercise_id' => $exercise_id]); }
public function getAllWithInfo() { return Response::json(Exercise::with('exerciseAlias', 'muscles', 'muscles.muscleAlias')->get()); }
public function allFromUser($user) { $exercises = Exercise::where('user_id', '>', $user)->get(); return view('exercises.index', compact('exercises')); }
/** * Remove the specified resource from storage. * * @param \App\Exercise $exercise * * @return \Illuminate\Http\Response */ public function destroy(Exercise $exercise) { $exercise->delete(); return response('This exercise has deleted.'); }
public function all() { if (!Auth::check()) { // The user is logged in... return redirect('auth/login'); } $exercises = Exercise::all(); return response()->json(array('success' => true, 'data' => $exercises)); }
/** * Execute the console command. * * @return mixed */ public function handle() { DB::enableQueryLog(); // Delete all data in the database, TODO: remove before production DB::statement("SET foreign_key_checks=0"); Exercise::truncate(); DB::statement("TRUNCATE TABLE `exercise_muscle`"); DB::statement("SET foreign_key_checks=1"); // Bench press $exercise = Exercise::create(['name' => 'Bench press']); $muscles = []; $muscles[] = ['Pectoralis Major Sternal Head', self::$max_intensity]; $muscles[] = ['Pectoralis Major Clavicular Head', self::$high_intensity]; $muscles[] = ['Triceps Brachii', self::$medium_intensity]; $muscles[] = ['Deltoid Anterior', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Bicep curl $exercise = Exercise::create(['name' => 'Bicep curl']); $muscles = []; $muscles[] = ['Biceps Brachii', self::$max_intensity]; $muscles[] = ['Brachialis', self::$medium_intensity]; $muscles[] = ['Brachioradialis', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Pull-up $exercise = Exercise::create(['name' => 'Pull-up']); $muscles = []; $muscles[] = ['Latissimus Dorsi', self::$max_intensity]; $muscles[] = ['Brachialis', self::$medium_intensity]; $muscles[] = ['Brachioradialis', self::$medium_intensity]; $muscles[] = ['Biceps Brachii', self::$medium_intensity]; $muscles[] = ['Teres Major', self::$medium_intensity]; $muscles[] = ['Deltoid Posterior', self::$medium_intensity]; $muscles[] = ['Infraspinatus', self::$medium_intensity]; $muscles[] = ['Teres Minor', self::$medium_intensity]; $muscles[] = ['Rhomboids', self::$medium_intensity]; $muscles[] = ['Levator Scapulae', self::$medium_intensity]; $muscles[] = ['Trapezius Lower Fibers Fibers', self::$medium_intensity]; $muscles[] = ['Trapezius Middle Fibers Fibers', self::$medium_intensity]; $muscles[] = ['Pectoralis Minor', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Overhead press $exercise = Exercise::create(['name' => 'Overhead press']); $muscles = []; $muscles[] = ['Deltoid Anterior', self::$max_intensity]; $muscles[] = ['Triceps Brachii', self::$medium_intensity]; $muscles[] = ['Pectoralis Major Clavicular Head', self::$medium_intensity]; $muscles[] = ['Trapezius Lower Fibers Fibers', self::$medium_intensity]; $muscles[] = ['Trapezius Middle Fibers', self::$medium_intensity]; $muscles[] = ['Deltoid Lateral', self::$medium_intensity]; $muscles[] = ['Serratus Anterior', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Skullcrusher $exercise = Exercise::create(['name' => 'Skull-crusher']); $muscles = []; $muscles[] = ['Triceps Brachii', self::$max_intensity]; $exercise->attachToMuscle($muscles); // Lateral raise $exercise = Exercise::create(['name' => 'Lateral raise']); $muscles = []; $muscles[] = ['Deltoid Lateral', self::$max_intensity]; $muscles[] = ['Deltoid Anterior', self::$medium_intensity]; $muscles[] = ['Trapezius Lower Fibers', self::$medium_intensity]; $muscles[] = ['Trapezius Middle Fibers', self::$medium_intensity]; $muscles[] = ['Serratus Anterior', self::$medium_intensity]; $muscles[] = ['Supraspinatus', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Squats $exercise = Exercise::create(['name' => 'Squats']); $muscles = []; $muscles[] = ['Gluteus Maximus', self::$max_intensity]; $muscles[] = ['Quadriceps', self::$high_intensity]; $muscles[] = ['Adductors', self::$medium_intensity]; $muscles[] = ['Soleus', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Front Squats $exercise = Exercise::create(['name' => 'Front squats']); $muscles = []; $muscles[] = ['Quadriceps', self::$max_intensity]; $muscles[] = ['Gluteus Maximus', self::$high_intensity]; $muscles[] = ['Adductors', self::$medium_intensity]; $muscles[] = ['Soleus', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Standing calf raise $exercise = Exercise::create(['name' => 'Standing calf raise']); $muscles = []; $muscles[] = ['Gastrocnemius', self::$max_intensity]; $muscles[] = ['Soleus', self::$medium_intensity]; $exercise->attachToMuscle($muscles); // Dips $exercise = Exercise::create(['name' => 'Triceps Dips']); $muscles = []; $muscles[] = ['Triceps Brachii', self::$max_intensity]; $muscles[] = ['Deltoid Anterior', self::$medium_intensity]; $muscles[] = ['Pectoralis Major Clavicular Head', self::$medium_intensity]; $muscles[] = ['Pectoralis Major Sternal Head', self::$medium_intensity]; $muscles[] = ['Pectoralis Minor', self::$medium_intensity]; $muscles[] = ['Rhomboids', self::$medium_intensity]; $muscles[] = ['Levator Scapulae', self::$medium_intensity]; $muscles[] = ['Latissimus Dorsi', self::$medium_intensity]; $exercise->attachToMuscle($muscles); }
/** * Delete the given Exercise. * * @param int $id * @return Redirect */ public function getDelete($id = null) { $exercise = Exercise::destroy($id); // Redirect to the group management page return redirect('admin/exercises')->with('success', Lang::get('message.success.delete')); }