/**
  * 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());
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return view('admin.stage.index')->withStages(Stage::all());
 }
示例#4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Get all stages
     $stages = Stage::all();
     return view('stages.index', compact('stages'));
 }