/** * Run the database seeds. * * @return void */ public function run() { DB::table('principles')->delete(); $focus = Focus::where('slug', 'attacking')->first(); DB::table('principles')->insert([['name' => 'Penetration', 'slug' => 'penetration', 'focus_id' => $focus->id], ['name' => 'Support', 'slug' => 'support', 'focus_id' => $focus->id], ['name' => 'Mobility', 'slug' => 'mobility', 'focus_id' => $focus->id], ['name' => 'Width', 'slug' => 'width', 'focus_id' => $focus->id], ['name' => 'Improvisation', 'slug' => 'improvisation', 'focus_id' => $focus->id]]); $focus = Focus::where('slug', 'defending')->first(); DB::table('principles')->insert([['name' => 'Pressure', 'slug' => 'pressure', 'focus_id' => $focus->id], ['name' => 'Delay', 'slug' => 'delay', 'focus_id' => $focus->id], ['name' => 'Cover', 'slug' => 'cover', 'focus_id' => $focus->id], ['name' => 'Balance', 'slug' => 'balance', 'focus_id' => $focus->id], ['name' => 'Compactness', 'slug' => 'compactness', 'focus_id' => $focus->id], ['name' => 'Control', 'slug' => 'control', 'focus_id' => $focus->id]]); $this->command->info('Principle 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) { return view('admin.principle.edit')->withPrinciple(Principle::findOrFail($id))->withFoci(Focus::all()); }
/** * Remove the specified resource from storage. * * @param integer $id Resource ID * * @return Response */ public function destroy($id) { Focus::findOrFail($id)->delete(); return redirect()->route('admin.focus.index')->withMessage('The requested focus has been deleted.'); }