public function validatePoll(Request $request, $eid)
 {
     $data = json_decode($request->getContent());
     $pollArray = $data->polloptions;
     //json list of poll options
     if (!empty($pollArray)) {
         $poll = new Poll();
         $poll->eid = $eid;
         $poll->polltype = 'date';
         $saveflag = $poll->save();
         if ($saveflag) {
             foreach ($pollArray as $poll_index) {
                 $poll_options = new PollOption();
                 $poll_options->pid = $poll['pid'];
                 $poll_options->option = $poll_index->option;
                 try {
                     PollOption::savePollOption($poll_options);
                 } catch (Exception $e) {
                     print '<script type="text/javascript">';
                     print 'alert( There have been issues adding options to your poll please
                     check home page for details)';
                     print '</script>';
                 }
             }
         } else {
             print '<script type="text/javascript">';
             print 'alert("Unable to save poll to database")';
             print '</script>';
         }
     }
 }
示例#2
0
 public function validatePoll($eid)
 {
     $input = Request::all();
     $dateList = $input['returndatepolls'];
     $pollArray = array_map('trim', explode(',', $dateList));
     if (!empty($pollArray)) {
         $poll = new Poll();
         $poll->eid = $eid;
         $poll->polltype = 'date';
         $saveflag = $poll->save();
         if ($saveflag) {
             foreach ($pollArray as $poll_index) {
                 $poll_options = new PollOption();
                 $poll_options->pid = $poll['pid'];
                 $poll_options->option = $poll_index;
                 try {
                     PollOption::savePollOption($poll_options);
                 } catch (Exception $e) {
                     print '<script type="text/javascript">';
                     print 'alert( There have been issues adding options to your poll please
                     check home page for details)';
                     print '</script>';
                     return view('events/invite_event');
                 }
             }
         } else {
             print '<script type="text/javascript">';
             print 'alert("Unable to save poll to database")';
             print '</script>';
             return view('events/create_poll');
         }
     }
     return view('events/invite_event')->with('eventID', $eid);
 }