public function store(CreateRegistrationRequest $request)
 {
     $data = $request->all();
     // Make sure the birthdate is properly formatted
     $data['birthdate'] = date("Y-m-d", strtotime($data['birthdate']));
     $registration = Registration::create($data);
     return response()->json(array(true));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $student = Auth::user();
     $regs = Registration::where('student_id', '=', $student->id)->get();
     if (count($regs) > 0) {
         Flash::error('You have completed registration!.');
         return redirect()->route('registration');
     }
     $courses = json_decode(stripslashes($request["courses_selected"]));
     $courses_unique = array_unique($courses);
     foreach ($courses_unique as $course) {
         Registration::create(['course_id' => $course, 'student_id' => $student->id]);
     }
     Flash::success('Registration complete.');
     return redirect()->route('registration.index');
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $circles = Circle::all();
     foreach ($circles as $circle) {
         $pupils = Pupil::where('schoolenrolment', $circle->year - $circle->grade + 1)->get();
         $count = rand(0, min(10, $pupils->count()));
         if ($count == 0) {
             continue;
         }
         if ($count == 1) {
             $pupil = $pupils->random();
             Registration::create(['circle_id' => $circle->id, 'pupil_id' => $pupil->id]);
         } else {
             $pupils = $pupils->random($count);
             foreach ($pupils as $pupil) {
                 Registration::create(['circle_id' => $circle->id, 'pupil_id' => $pupil->id]);
             }
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
     Registration::create($request->all());
     return redirect('registration');
 }