public function programDetail($id)
 {
     $regDetails = RegistrationDetails::find($id);
     if (!$regDetails) {
         return Response::json(array('status' => 'failure', 'msg' => 'No data present'));
     }
     $username = $regDetails->user_name;
     // check user application is approved or not
     $status = Curl::postCurl($_ENV['core'] . '/getForEbookStatus/' . $username);
     $status = json_decode(json_encode($status), true);
     if (isset($status['error'])) {
         return Response::json(array('status' => 'failure', 'msg' => $status['error']));
     }
     $coreApplicantDetails = Curl::postCurl($_ENV['core'] . '/listApplicantDetailsCore/' . $username);
     $coreApplicantDetails = json_decode(json_encode($coreApplicantDetails), true);
     $details = array();
     $details[0]['reg_id'] = "UOM_" . $status['success']['id'];
     if (isset($coreApplicantDetails['success']['Data']['0']['Program Details'][0]['program_name'])) {
         $programId = $coreApplicantDetails['success']['Data'][0]['Program Details'][0]['program_name'];
         $data = Curl::postCurl($_ENV['core'] . '/listAvailableProgram/' . $programId);
         $data = json_decode(json_encode($data), true);
         if (isset($data)) {
             $programDetails = $data['success']['Data'];
             foreach ($programDetails as $key => $value) {
                 $programName = $value['program_name'];
                 $desc = $value['program_description'];
             }
         }
         $details[0]['programId'] = $programId;
         $details[0]['programName'] = $programName;
         $details[0]['programDesc'] = $desc;
     }
     $courseDetails = Curl::postCurl($_ENV['core'] . '/listAvailableCourse/' . $programId);
     $courseDetails = json_decode(json_encode($courseDetails), true);
     $courseDetails = $courseDetails['success']['Data'];
     $courses = array();
     foreach ($courseDetails as $key => $value) {
         $courseArray['course_semester'] = $value['course_semester'];
         $courseArray['course_name'] = $value['course_name'];
         $courses[] = $courseArray;
     }
     // if (count($courses)>0)
     //  $details[0]['course'] = $courses;
     return Response::json(array('status' => 'success', 'data' => $details, 'course' => $courses));
 }
 public function fillAcademicDetails(Request $request)
 {
     $data = $request->all();
     if (!isset($data['id'])) {
         return Response::json(array('status' => "failure", "msg" => "Incorrect Information"));
     }
     $userDetails = RegistrationDetails::find($data['id']);
     if (!$userDetails) {
         return Response::json(array('status' => "failure", "msg" => "Wrong id"));
     }
     $AcadDetail = Academics::where('registration_id', '=', $data['id'])->first();
     if (!$AcadDetail) {
         $AcadDetail = new Academics();
         $AcadDetail->registration_id = $data['id'];
     }
     $AcadDetail->fill($data);
     if ($AcadDetail->save()) {
         return Response::json(array('status' => 'success', 'msg' => 'Data has been saved successfully', 'data' => $AcadDetail));
     }
     return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving data'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     if (!isset($data['id']) || !isset($data['data'])) {
         return Response::json(array('status' => 'failure', 'msg' => 'Invalid arguments'));
     }
     $regId = $data['id'];
     // check whether the user is presnt or not
     $userDetails = RegistrationDetails::find($regId);
     if (!$userDetails) {
         return Response::json(array('status' => 'failure', 'msg' => 'User is not present in the system'));
     }
     $academicData = json_decode($data['data']);
     $academic = AcademicDocumentUpload::where('registration_id', '=', $regId)->first();
     if (!$academic) {
         $academic = new AcademicDocumentUpload();
         $academic->registration_id = $regId;
     }
     $tenDocumentString = '';
     foreach ($academicData as $k => $v) {
         $string = $this->generateDocumentString($v->document, $v->type, $v->image);
         $documentString = $string['string'];
         $imageUploadArray[$k] = $string['image'];
         if ($v->document == 'x_document') {
             $academic->x_document = $academic->x_document . "|" . $documentString;
         }
         if ($v->document == 'xii_document') {
             $academic->xii_document = $academic->xii_document . "|" . $documentString;
         }
         if ($v->document == 'graduation_document') {
             $academic->graduation_document = $academic->graduation_document . "|" . $documentString;
         }
         if ($v->document == 'other_document1') {
             $academic->other_document1 = $academic->other_document1 . "|" . $documentString;
         }
         if ($v->document == 'other_document2') {
             $academic->other_document2 = $academic->other_document2 . "|" . $documentString;
         }
     }
     if (!$academic->save()) {
         return Response::json(array('status' => 'failure', 'msg' => 'Problem in uploading document'));
     }
     // save the images at server
     foreach ($imageUploadArray as $key => $value) {
         $multi = $this->checkMultiDimArray($value);
         if ($multi) {
             foreach ($value as $k => $v) {
                 if (file_put_contents($regId . '/' . $v['name'], $v['value'])) {
                     continue;
                 } else {
                     return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving document'));
                 }
             }
         } else {
             if (file_put_contents($regId . '/' . $value['name'], $value['value'])) {
                 continue;
             } else {
                 return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving document'));
             }
         }
     }
     return Response::json(array('status' => 'success', 'msg' => 'Document uploaded successfully'));
 }
 public function voiceCall(Request $request)
 {
     $data = $request->all();
     if (isset($data['id'])) {
         Response::json(array("status" => 'failure', "msg" => 'Missing argument'));
     }
     $regDetails = RegistrationDetails::find($data['id']);
     if (!$regDetails) {
         return Response::json(array("status" => "failure", "msg" => "No data is present"));
     }
     $phone_no = $regDetails->phone_no;
     $country = $regDetails->country;
     if (!$country) {
         return Response::json(array("status" => "failure", "msg" => "Country missing"));
     }
     $countryData = Country::where('name', "LIKE", $country)->first();
     $phnCode = $countryData->phonecode;
     $phone = "+" . $phnCode . $phone_no;
     $mCode = $this->generateRandomString(4);
     $array = str_split($mCode);
     $regDetails->mobile_code = $mCode;
     $regDetails->save();
     $twilio = Twilio::call($phone, $_ENV['app_url'] . "/callForMobileCode/{$array['0']}/{$array['1']}/{$array['2']}/{$array['3']}");
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     if (!isset($data['id'])) {
         return Response::json(array('status' => "failure", "msg" => "Incorrect Information"));
     }
     $userDetails = RegistrationDetails::find($data['id']);
     if (!$userDetails) {
         return Response::json(array('status' => "failure", "msg" => "Wrong id"));
     }
     $empDetail = Employability::where('registration_id', '=', $data['id'])->first();
     if (!$empDetail) {
         $empDetail = new Employability();
         $empDetail->registration_id = $data['id'];
     } else {
         // delete the details if they are already present
         // then insert the new entries
         $deleteDetails = Employability::where('registration_id', '=', $data['id'])->delete();
         $empDetail = new Employability();
         $empDetail->registration_id = $data['id'];
     }
     if ($data['company1'] != null) {
         $empDetail->work_experience_year = $data['work_experience_year'];
         $empDetail->work_experience_month = $data['work_experience_month'];
         $empDetail->fill(json_decode($data['company1'], true));
         if (!$empDetail->save()) {
             return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving data'));
         }
     }
     if ($data['company2'] != null) {
         $empDetail = new Employability();
         $empDetail->registration_id = $data['id'];
         $empDetail->work_experience_year = $data['work_experience_year'];
         $empDetail->work_experience_month = $data['work_experience_month'];
         $empDetail->fill(json_decode($data['company2'], true));
         if (!$empDetail->save()) {
             return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving data'));
         }
     }
     if ($data['company3'] != null) {
         $empDetail = new Employability();
         $empDetail->registration_id = $data['id'];
         $empDetail->work_experience_year = $data['work_experience_year'];
         $empDetail->work_experience_month = $data['work_experience_month'];
         $empDetail->fill(json_decode($data['company3'], true));
         if (!$empDetail->save()) {
             return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving data'));
         }
     }
     if ($data['company4'] != null) {
         $empDetail = new Employability();
         $empDetail->registration_id = $data['id'];
         $empDetail->work_experience_year = $data['work_experience_year'];
         $empDetail->work_experience_month = $data['work_experience_month'];
         $empDetail->fill(json_decode($data['company4'], true));
         if (!$empDetail->save()) {
             return Response::json(array('status' => 'failure', 'msg' => 'Problem in saving data'));
         }
     }
     return Response::json(array('status' => 'success', 'msg' => 'Data has been saved successfully'));
 }