Exemplo n.º 1
0
 /**
  * Listing the Course for an Age Group
  * @param  int $id 
  * @return App\Course
  */
 public function listCourses($id)
 {
     $ageGroup = AgeGroup::with(['courses' => function ($query) {
         $query->with('days');
     }])->whereId($id)->get();
     return $ageGroup;
 }
Exemplo n.º 2
0
 /**
  * Returns the age group names
  *
  * @return string
  */
 public function getAgeGroupsAttribute()
 {
     $out = array();
     foreach ($this->age_id as $id) {
         $ageGroup = AgeGroup::where('id', $id);
         if ($ageGroup->count() === 1) {
             $out[] = $ageGroup->first()->name;
         }
     }
     return join(', ', $out);
 }
Exemplo n.º 3
0
 public function run()
 {
     // DB::table('age_groups')->delete();
     DB::table('age_groups')->truncate();
     $age_group_1 = AgeGroup::create(array('age_group' => '0 - 10'));
     $age_group_2 = AgeGroup::create(array('age_group' => '11 - 18'));
     $age_group_3 = AgeGroup::create(array('age_group' => '19 - 25'));
     $age_group_4 = AgeGroup::create(array('age_group' => '26 - 30'));
     $age_group_5 = AgeGroup::create(array('age_group' => '31 - 35'));
     $age_group_6 = AgeGroup::create(array('age_group' => '35 - Above'));
 }
 /**
  * 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);
 }
 /**
  * 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());
 }
Exemplo n.º 7
0
 /**
  * Edit the Child
  * @param  int $id 
  * @return \Illuminate\Http\Response
  */
 public function editChild($id)
 {
     $child = \App\Child::with('phones', 'address')->findOrFail($id);
     $groups = \App\AgeGroup::where('on_site', "=", 1)->where('published', "=", 1)->lists('name', 'id');
     $agegroup = \App\AgeGroup::find(1);
     $courses = $agegroup->courses;
     $states = \App\State::lists('name', 'id');
     return view('register.child', compact('child', 'groups', 'states'));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param integer $id Resource ID
  *
  * @return Response
  */
 public function destroy($id)
 {
     AgeGroup::findOrFail($id)->delete();
     return redirect()->route('admin.age-group.index')->withMessage('The requested age group has been deleted.');
 }