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');
 }
예제 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $advisor = new Advisor();
     $advisor->adv_fname = $request->fname;
     $advisor->adv_lname = $request->lname;
     $advisor->adv_password = $request->password;
     $advisor->adv_email = $request->email;
     $advisor->is_active = true;
     $advisor->save();
     //return view('advisor/advisor_create',['main_title'=>'Advisor Panel' ,'sub_title' => 'Register Advisor']);
     return redirect()->route('advisor.index');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $advisor = new Advisor();
     $advisor->name = 'Testing Testerman';
     $advisor->email = '*****@*****.**';
     $advisor->attending_advisor = 'Testie Testerman';
     $advisor->comments = 'These are comments.';
     $advisor->event_id = 1;
     $advisor->school_id = 1;
     $advisor->save();
     $advisor = new Advisor();
     $advisor->name = 'Testing Testerman 2';
     $advisor->email = '*****@*****.**';
     $advisor->attending_advisor = 'Testie Testerman 2';
     $advisor->comments = 'These are comments.';
     $advisor->event_id = 1;
     $advisor->school_id = 1;
     $advisor->save();
 }