/** * Returns the principle names * * @return string */ public function getPrinciplesAttribute() { $out = array(); foreach ($this->principle_id as $id) { $principle = Principle::where('id', $id); if ($principle->count() === 1) { $out[] = $principle->first()->name; } } return join(', ', $out); }
/** * Run the database seeds. * * @return void */ public function run() { $ageGroupIds = array(); foreach (AgeGroup::all() as $ageGroup) { $ageGroupIds[] = $ageGroup->id; } $principleIds = array(); foreach (Principle::all() as $principle) { $principleIds[] = $principle->id; } DB::table('drills')->delete(); DB::table('drills')->insert([['name' => 'Close Cone Passes', 'slug' => 'close-cone-passes', 'stage_id' => Stage::where('slug', 'warmup')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Close Cone Passes 2', 'slug' => 'close-cone-passes', 'stage_id' => Stage::where('slug', 'warmup')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Close Cone Passes 3', 'slug' => 'close-cone-passes', 'stage_id' => Stage::where('slug', 'warmup')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Short Short Long', 'slug' => 'short-short-long', 'stage_id' => Stage::where('slug', 'small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Short Short Long 2', 'slug' => 'short-short-long', 'stage_id' => Stage::where('slug', 'small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Shooter Keep Shooting', 'slug' => 'shooter-keep-shooting', 'stage_id' => Stage::where('slug', 'modified-small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Short Short Long 2', 'slug' => 'short-short-long', 'stage_id' => Stage::where('slug', 'small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Short Short Long 3', 'slug' => 'short-short-long', 'stage_id' => Stage::where('slug', 'small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Short Short Long 4', 'slug' => 'short-short-long', 'stage_id' => Stage::where('slug', 'small-sided-game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Small Cones Outside Game', 'slug' => 'small-cones-outside-game', 'stage_id' => Stage::where('slug', 'game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif'], ['name' => 'Small Cones Outside Game 2', 'slug' => 'small-cones-outside-game', 'stage_id' => Stage::where('slug', 'game')->first()->id, 'age_id' => json_encode($ageGroupIds), 'principle_id' => json_encode($principleIds), 'image' => 'img/drills/100_shooter_keeper_shooting.gif']]); $this->command->info('Drill table seeded!'); }
/** * Display the random practice plan * * @param string $ageGroup Age group slug * @param string $focus Focus slug * @param string $principle Principle slug * * @return Response */ public function plan($ageGroup, $focus, $principle, Request $request) { $savedDrills = $request->input('saved_drills') ? $request->input('saved_drills') : array(); $ageGroupModel = AgeGroup::where('slug', $ageGroup); if ($ageGroupModel->count() < 1) { return redirect()->route('home'); } if (Focus::where('slug', $focus)->count() < 1) { return redirect()->route('home.focus', $ageGroup); } $principleModel = Principle::where('slug', $principle); if ($principleModel->count() < 1) { return redirect()->route('home.principle', $ageGroup, $focus); } $drills = array(); foreach (Stage::all() as $stage) { $drill = null; if (array_key_exists($stage->id, $savedDrills)) { $drill = Drill::where('id', $savedDrills[$stage->id])->first(); $drill->saved = true; } if (!$drill) { $drill = Drill::where('stage_id', $stage->id)->get()->random(); } // Filter out age groups if (!in_array($ageGroupModel->get()->first()->id, $drill->age_id)) { continue; } // Filter out principles if (!in_array($principleModel->get()->first()->id, $drill->principle_id)) { continue; } $drill->notes = str_replace("\n", '<br>', $drill->notes); $drill->coaching_points = str_replace("\n", '<br>', $drill->coaching_points); $drills[] = $drill; } return view('home.plan')->with('ageGroup', $ageGroup)->withFocus($focus)->withPrinciple($principle)->withDrills($drills); }
/** * Remove the specified resource from storage. * * @param int $id Resource ID * * @return Response */ public function destroy($id) { Principle::findOrFail($id)->delete(); return redirect()->route('admin.principle.index')->withMessage('The requested principle has been deleted.'); }
/** * Show the form for editing the specified resource. * * @param int $id Resource ID * * @return Response */ public function edit($id) { $drill = Drill::findOrFail($id); return view('admin.drill.edit')->withDrill(Drill::findOrFail($id))->with('ageGroups', AgeGroup::all())->withPrinciples(Principle::all())->withStages(Stage::all()); }