public function post(Step2Request $request)
 {
     // if id is found, update advisor
     if ($advisor_id = $request->input('id')) {
         $advisor = Advisor::find($advisor_id);
         $advisor->update($request->all());
     } else {
         // create new advisor
         $advisor = new Advisor($request->all());
         $advisor->school_id = Session::get('school')->id;
         $advisor->event_id = Session::get('event')->id;
         $advisor->save();
     }
     Session::set('advisor', Advisor::find($advisor->id));
     if (!$request->input('other_school')) {
         // auto create first advisor
         $attendee = new Attendee();
         // split up the attending advisor name
         $attendee_name = explode(' ', $request->input('attending_advisor'));
         if (is_array($attendee_name) && count($attendee_name) > 1) {
             $attendee->first_name = $attendee_name[0];
             $attendee->last_name = $attendee_name[1];
         } else {
             $attendee->first_name = $request->input('attending_advisor');
             $attendee->last_name = '';
         }
         $attendee->event_id = Session::get('event')->id;
         $attendee->school_id = Session::get('school')->id;
         $attendee->role_id = Role::where(['name' => 'Advisor', 'event_id' => Session::get('event')->id])->first()->id;
         $attendee->advisor_id = Session::get('advisor')->id;
         $attendee->save();
         Flash::info(trans('notifications.edit_as_needed'));
     }
     return redirect('/event/' . Session::get('event')->slug . '/step/3');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(AttendeeRequest $request, Attendee $attendee)
 {
     $attendee->delete();
     if ($request->ajax() || $request->wantsJson()) {
         return new JsonResponse($attendee);
     }
     return redirect('attendees');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 30) as $index) {
         Attendee::create(['first_name' => $faker->firstNameMale(), 'last_name' => $faker->lastName(), 'suffix' => $index % 5 ? NULL : $faker->suffix(), 'identifier' => $faker->regexify('[A-Z]?[0-9]{3}/[0-9]{3}')]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Attendee::create(['event_id' => 1, 'school_id' => 1, 'role_id' => 1, 'last_name' => 'Testerman', 'first_name' => 'Test', 'gender' => 'M', 'grade' => 0, 'special_diet' => 'Test diet', 'bringing_meds' => 1, 'special_needs' => 'Testing needs', 'advisor_id' => 1]);
     Attendee::create(['event_id' => 1, 'school_id' => 1, 'role_id' => 2, 'last_name' => 'Testerman 2', 'first_name' => 'Test 2', 'gender' => 'F', 'grade' => 9, 'special_diet' => 'Test diet 2', 'bringing_meds' => 0, 'special_needs' => 'Testing needs 2', 'advisor_id' => 1]);
     Attendee::create(['event_id' => 1, 'school_id' => 1, 'role_id' => 1, 'last_name' => 'Testerman', 'first_name' => 'Test', 'gender' => 'M', 'grade' => 0, 'special_diet' => 'Test diet', 'bringing_meds' => 1, 'special_needs' => 'Testing needs', 'advisor_id' => 2]);
     Attendee::create(['event_id' => 1, 'school_id' => 1, 'role_id' => 1, 'last_name' => 'Testerman', 'first_name' => 'Test', 'gender' => 'M', 'grade' => 0, 'special_diet' => 'Test diet', 'bringing_meds' => 1, 'special_needs' => 'Testing needs', 'advisor_id' => 2]);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('attendees', function ($id) {
         return \App\Attendee::where('id', $id)->firstOrFail();
     });
     parent::boot($router);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $attendeeIds = Attendee::lists('id')->all();
     $counselorIds = Counselor::lists('id')->all();
     foreach ($attendeeIds as $attendeeId) {
         DB::table('attendee_counselor')->insert(['attendee_id' => $attendeeId, 'counselor_id' => $faker->randomElement($counselorIds), 'created_at' => Carbon::now()]);
     }
 }
Exemplo n.º 7
0
 public static function total()
 {
     $total = 0;
     $attendees = Attendee::where(['event_id' => Session::get('event')->id, 'school_id' => Session::get('school')->id])->get();
     foreach ($attendees as $attendee) {
         // add to total
         $total += $attendee->role->cost;
     }
     return $total;
 }
Exemplo n.º 8
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $attendee = Attendee::find($this->attendees);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['event_id' => 'required|not_in:0', 'fname' => 'required', 'lname' => 'required', 'email' => 'required|email|unique:attendees,email'];
         case 'PUT':
         case 'PATCH':
             return ['event_id' => 'required|not_in:0', 'fname' => 'required', 'lname' => 'required', 'email' => 'required|email|unique:attendees,email,' . $attendee->id];
         default:
             break;
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $attendeeIds = Attendee::lists('id')->all();
     $programIds = Program::lists('id')->all();
     $counter = 0;
     foreach ($attendeeIds as $attendeeId) {
         $completion_date = $termination_date = NULL;
         if (($counter + 1) % 6 == 0) {
             $completion_date = $faker->dateTimeBetween($startDate = '-6 months');
         } else {
             if (($counter + 1) % 13 == 0) {
                 $termination_date = $faker->dateTimeBetween($startDate = '-6 months');
             }
         }
         DB::table('enrollments')->insert(['attendee_id' => $attendeeId, 'program_id' => $faker->randomElement($programIds), 'start_date' => $faker->dateTimeBetween($startDate = '-12 months'), 'completion_date' => $completion_date, 'termination_date' => $termination_date, 'created_at' => Carbon::now()]);
         $counter++;
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     if (!Input::get('attendee_id') or !Input::get('program_id')) {
         return $this->respondUnprocessableEntity('Parameters failed validation for an enrollment.');
     }
     try {
         $attendee = Attendee::findOrFail(Input::get('attendee_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Attendee provided does not exist.');
     }
     try {
         $program = Program::findOrFail(Input::get('program_id'));
     } catch (ModelNotFoundException $e) {
         return $this->respondUnprocessableEntity('Program provided does not exist.');
     }
     $existingEnrollment = Enrollment::where('attendee_id', $attendee->id)->where('program_id', $program->id)->whereNull('enrollments.deleted_at')->get();
     if (count($existingEnrollment)) {
         return $this->respondUnprocessableEntity('The enrollment of the attendee to the program already exists.');
     }
     //We pass validation. Now add the enrollment.
     Enrollment::create(Input::all());
     return $this->respondCreated('Enrollment created successfully.');
 }
 public function postLogin(LoginRequest $request, Attendee $attendee)
 {
     // Pagina waar wordt gecheckt of het opgegeven emailadres voorkomt in de tabel 'attendees'
     $deattendee = $attendee->where('email', $request->get('email'))->first();
     if ($deattendee == null) {
         $newattendee = new $attendee(['email' => $request->get('email'), 'ref' => $request->get('ref')]);
         $newattendee->save();
         $data = ['voornaam' => null, 'achternaam' => null, 'email' => $request->get('email')];
         // Verstuur kopie naar Digitus
         Mail::send('includes.email.webinars.superboost', $data, function ($message) use($data) {
             $message->from('*****@*****.**', 'Digitus Marketing');
             $message->to('*****@*****.**', 'Digitus Marketing')->subject('Iemand heeft zich zojuist aangemeld voor het Superboost je bereik Webinar');
         });
         // Doe iets omdat $deattendee niet bestaat
         return redirect()->back()->with(['message' => 'Het lijkt er op dat je je niet hebt aangemeld voor dit online event. We hebben je ingeschreven, je kunt je nu aanmelden voor dit online event! Probeer het nogmaals :)']);
         // dd($deattendee);
     } else {
         // Doe iets omdat $deattendee bestaat
         \Session::put('deattendee', $deattendee);
         return redirect('/superboost/onlineevent')->with(['message' => 'Succes']);
         // dd($deattendee);
     }
 }
Exemplo n.º 12
0
 public function manage()
 {
     $attendees = Attendee::paginate(5);
     return view('attendees.manage', compact('attendees'));
 }
Exemplo n.º 13
0
 public function removeAttendee(RemoveAttendeeRequest $request)
 {
     Attendee::find($request->input('attendee_id'))->delete();
     return redirect('/event/' . Session::get('event')->slug . '/step/3');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $attendee = Attendee::find($id);
     if (!$attendee) {
         return $this->respondNotFound('Attendee does not exist.');
     }
     if ($attendee->delete()) {
         return $this->respond(['message' => 'The attendee has been deleted.']);
     } else {
         return $this->respondUnprocessableEntity('There was a problem deleting the attendee.');
     }
 }
 /**
  * Displays the counselor that an attendee is assigned to.
  *
  * @return \Illuminate\Http\Response
  */
 public function byAttendee($attendeeId = null)
 {
     $counselor = $attendeeId ? Attendee::findOrFail($attendeeId)->counselor : null;
     return $this->respond(['data' => $this->counselorTransformer->transform($counselor)]);
 }
 public function postHerhalingLogin($slug, Webinar $w, Webinarherhaling $wh, Attendee $a, LoginRequest $request)
 {
     $webinar = $w->where('slug', $slug)->first();
     $hetwebinar = $webinar->webinarherhaling->first();
     // Pagina waar wordt gecheckt of het opgegeven emailadres voorkomt in de tabel 'attendees'
     $deattendee = $a->where('email', $request->get('email'))->first();
     if ($deattendee == null) {
         $newattendee = new $a(['email' => $request->get('email'), 'ref' => $request->get('ref')]);
         $newattendee->save();
         $newattendee->webinars()->attach($hetwebinar->webinars->first()->id);
         $data = ['voornaam' => null, 'achternaam' => null, 'email' => $request->get('email'), 'webinartitel' => $hetwebinar->webinars->first()->titel];
         // Verstuur kopie naar Digitus
         Mail::send('includes.email.webinars.aanmeld', $data, function ($message) use($data) {
             $message->from('*****@*****.**', 'Digitus Marketing');
             $message->to('*****@*****.**', 'Digitus Marketing')->subject('Iemand heeft zich zojuist aangemeld voor het ' . $data['webinartitel'] . ' Webinar');
         });
         // Doe iets omdat $deattendee niet bestaat
         return redirect()->back()->with(['message' => 'Het lijkt er op dat je je niet hebt aangemeld voor dit online event. We hebben je ingeschreven, je kunt je nu aanmelden voor dit online event! Probeer het nogmaals :)']);
         // dd($deattendee);
     } else {
         // Doe iets omdat $deattendee bestaat
         if ($deattendee->webinars->contains($hetwebinar->webinars->first()->id)) {
             $deattendee->update(['ref' => $request->get('ref')]);
             \Session::put('deattendee', $deattendee);
             return redirect()->action('WebinarController@getHerhaling', array($hetwebinar->webinars->first()->slug))->with(['message' => 'Succes']);
         } else {
             $deattendee->update(['ref' => $request->get('ref')]);
             $deattendee->webinars()->attach($hetwebinar->webinars->first()->id);
             return redirect()->back()->with(['message' => 'Het lijkt er op dat er iets mis is gegaan.. Probeer het opnieuw']);
         }
     }
 }
 /**
  * Output table data as csv.
  */
 public function export($format = 'csv')
 {
     // grab data
     $data = Attendee::select('attendees.id as AttendeeID', 'attendees.created_at as RegTime', 'schools.region as Region', 'roles.name as Role', 'attendees.last_name as NameLast', 'attendees.first_name as NameFirst', 'attendees.gender as Gender', 'attendees.grade as Grade', 'attendees.special_diet as SpecialDiet', 'attendees.bringing_meds as BringingMeds', 'attendees.special_needs as SpecialNeeds', 'advisors.name as RegisteredBy', 'attendees.housing_code as HousingCode', 'attendees.shirt_size as TShirtSize')->leftJoin('roles', 'roles.id', '=', 'attendees.role_id')->leftJoin('advisors', 'advisors.id', '=', 'attendees.advisor_id')->join('schools', 'schools.id', '=', 'advisors.school_id')->get();
     // create empty file
     $csv = Writer::createFromFileObject(new \SplTempFileObject());
     // create header
     $csv->insertOne(['AttendeeID', 'RegTime', 'Region', 'Role', 'NameLast', 'NameFirst', 'Gender', 'Grade', 'SpecialDiet', 'BringingMeds', 'SpecialNeeds', 'RegisteredBy', 'HousingCode', 'TShirtSize']);
     // insert rows as associative array
     $csv->insertAll($data->toArray());
     $csv->output('attendees_' . \Carbon\Carbon::now()->timestamp . '.csv');
 }