예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $course = new Course();
     $page = Page::findOrFail($request->page);
     $study = Study::findOrFail($request->study);
     $course->study()->associate($study);
     $course->page()->associate($page);
     $course->quartile = $request->quartile;
     $course->save();
     return redirect(route("course::list"));
 }
예제 #2
0
 public function link($user_id, Request $request)
 {
     $user = User::findOrFail($user_id);
     if ($user->id != Auth::id() && !Auth::user()->can('board')) {
         abort(403);
     }
     $study = Study::findOrFail($request->study);
     $link = new StudyEntry();
     if (($link->created_at = date('Y-m-d H:i:s', strtotime($request->start))) === false || $request->start == "") {
         Session::flash("flash_message", "Ill-formatted start date.");
         return Redirect::back();
     }
     $link->deleted_at = null;
     if ($request->end != "" && ($link->deleted_at = date('Y-m-d H:i:s', strtotime($request->end))) === false) {
         Session::flash("flash_message", "Ill-formatted end date.");
         return Redirect::back();
     }
     $link->user()->associate($user);
     $link->study()->associate($study);
     $link->save();
     Session::flash("flash_message", "Your study has been saved.");
     return Redirect::route('user::dashboard', ['id' => $user->id]);
 }