コード例 #1
0
ファイル: DrillController.php プロジェクト: cmon2/whiteboard
 public function create(Request $request)
 {
     $drill = new Drill();
     $drill->name = $request->input('name');
     $drill->save();
     return view('design/drill');
 }
コード例 #2
0
ファイル: PlanController.php プロジェクト: cmon2/whiteboard
 public function create(Request $request)
 {
     $plan = new Plan();
     $plan->subject = $request->input('name');
     $plan->save();
     $drills = $request->input('drill');
     foreach ($drills as $drill) {
         $drill = Drill::where('name', '=', $drill)->get()->first();
         $plan->drills()->attach($drill->id);
     }
     $drills = Drill::orderBy('created_at', 'asc')->get();
     return view('design/plan', ['drills' => $drills]);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id Resource ID
  *
  * @return Response
  */
 public function destroy($id)
 {
     Drill::findOrFail($id)->delete();
     // TODO Delete the image from the directory?
     return redirect()->route('admin.drill.index')->withMessage('The requested drill has been deleted.');
 }
コード例 #5
0
 public function showDrills()
 {
     $drills = Drill::orderBy('created_at', 'asc')->get();
     return view('navigation/drills', ['drills' => $drills]);
 }