Esempio n. 1
0
 public function history(Request $request)
 {
     $this->validate($request, ['id' => 'required', 'type' => 'required|in:1,-1']);
     $user = Auth::user();
     $id = $request->input('id');
     $value = $request->input('type');
     $history = History::find($id);
     $isLiked = $this->commit($user, $history, $id, $value);
     return ['hasCallback' => 1, 'callback' => 'history_liked', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_like' => $history->num_like, 'num_dislike' => $history->num_dislike, 'is_liked' => $isLiked]];
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->input();
     if ($input['level'] == 1) {
         /*$photo = array('resume_photo' => Input::file('resume_photo'),'passport' =>Input::file('passport'));
         			$rules = array('resume_photo' => 'required');//mimes:jpeg,bmp,png|max:10000','passport' => 'required|mimes:jpeg,png,pdf,doc|max:10000'); //mimes:jpeg,bmp,png and for max size max:10000
           // doing the validation, passing post data, rules and the messages
         $validator = Validator::make($photo, $rules);
         if ($validator->fails()) {
             // send back to the page with the input data and errors
         	return Redirect::to('resume.create')->withInput()->withErrors($validator);
         }
         else {*/
         if (Input::file('resume_photo')) {
             $resume_photo = array('file' => Input::file('resume_photo'), 'extention' => Input::file('resume_photo')->getClientOriginalExtension());
             $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png');
             $validator = Validator::make($resume_photo, $rules);
             if ($validator->fails()) {
                 // send back to the page with the input data and errors
                 // $validator->errors()->add('resume_photo', 'Invalide File');
                 Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png');
                 return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
             } else {
                 $destinationPath = 'upload';
                 $photoExtension = Input::file('resume_photo')->getClientOriginalExtension();
                 $photoName = rand(11111, 99999) . '_photo' . '.' . $photoExtension;
                 Input::file('resume_photo')->move($destinationPath, $photoName);
             }
         }
         if (Input::file('passport')) {
             $passport = array('file' => Input::file('passport'), 'extention' => Input::file('passport')->getClientOriginalExtension());
             $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx');
             $validator = Validator::make($passport, $rules);
             if ($validator->fails()) {
                 // send back to the page with the input data and errors
                 // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png');
                 Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx');
                 return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
             } else {
                 $destinationPath = 'upload';
                 $passportExtension = Input::file('passport')->getClientOriginalExtension();
                 $passportName = rand(11111, 99999) . '_passport' . '.' . $passportExtension;
                 Input::file('passport')->move($destinationPath, $passportName);
             }
         }
         $ret = PersonalInformation::where('id', $input['resumeId'])->first();
         if ($ret) {
             $resume = PersonalInformation::find($input['resumeId']);
             $resume->fname = $input['fname'];
             $resume->lname = $input['lname'];
             $resume->resume_photo = isset($photoName) ? $photoName : $ret->resume_photo;
             $resume->passport = isset($passportName) ? $passportName : $ret->passport;
             $resume->dob = $input['dob'];
             $resume->age = $input['age'];
             $resume->gender = $input['gender'];
             $resume->height = $input['height'];
             $resume->email = $input['email'];
             $resume->nationality = $input['nationality'];
             $resume->mobile = $input['mobile'];
             $resume->onumber = isset($input['onumber']) ? $input['onumber'] : '';
             $resume->raddress1 = $input['raddress1'];
             $resume->raddress2 = $input['raddress2'];
             $resume->city = isset($input['city']) ? $input['city'] : '';
             $resume->postal_code = $input['postal_code'];
             $resume->country = $input['country'];
             $resume->state = $input['state'];
             $resume->identification = $input['identification'];
             $resume->inumber = $input['inumber'];
             $resume->save();
             $rethistory = History::whereAction_idAndAction($resume->id, 'Resume Updated')->first();
             if ($rethistory) {
                 $history = History::find($rethistory->id);
                 $history->action = 'Resume Updated';
                 $history->user = Auth::user()->name;
                 $history->remark = '';
                 $history->save();
             } else {
                 $history = new History();
                 $history->action_id = $resume->id;
                 $history->action = 'Resume Updated';
                 $history->user = Auth::user()->name;
                 $history->remark = '';
                 $history->save();
             }
         } else {
             $resume = new PersonalInformation();
             $resume->agent_id = Auth::user()->id;
             $resume->approval_status = 0;
             $resume->approved_by = 0;
             $resume->agent_approval_delete = 0;
             $resume->fname = $input['fname'];
             $resume->lname = $input['lname'];
             $resume->resume_photo = isset($photoName) ? $photoName : '';
             $resume->passport = isset($passportName) ? $passportName : '';
             $resume->dob = $input['dob'];
             $resume->age = $input['age'];
             $resume->gender = $input['gender'];
             $resume->height = $input['height'];
             $resume->email = $input['email'];
             $resume->nationality = $input['nationality'];
             $resume->mobile = $input['mobile'];
             $resume->onumber = isset($input['onumber']) ? $input['onumber'] : '';
             $resume->raddress1 = $input['raddress1'];
             $resume->raddress2 = $input['raddress2'];
             $resume->city = isset($input['city']) ? $input['city'] : '';
             $resume->postal_code = $input['postal_code'];
             $resume->country = $input['country'];
             $resume->state = $input['state'];
             $resume->identification = $input['identification'];
             $resume->inumber = $input['inumber'];
             $resume->save();
             $history = new History();
             $history->action_id = $resume->id;
             $history->action = 'Resume Created';
             $history->user = Auth::user()->name;
             $history->remark = '';
             $history->save();
         }
         return view('resume.create')->with('id', $resume->id)->with('state', $input['level'] + 1);
         //}
     }
     if ($input['level'] == 2 && $input['resumeId'] > 0) {
         $eduChecked = Input::get('edu');
         if ($eduChecked) {
             $edudel = EducationalInformation::where('pid', $input['resumeId'])->whereNotIn('degree', $eduChecked)->delete();
             foreach ($eduChecked as $educationChecked) {
                 if ($educationChecked == 'phd') {
                     $prefe = 1;
                 } else {
                     if ($educationChecked == 'master') {
                         $prefe = 2;
                     } else {
                         if ($educationChecked == 'bachelor') {
                             $prefe = 3;
                         } else {
                             if ($educationChecked == 'intermediate') {
                                 $prefe = 4;
                             } else {
                                 if ($educationChecked == 'slc') {
                                     $prefe = 5;
                                 } else {
                                     $prefe = 6;
                                 }
                             }
                         }
                     }
                 }
                 $ret = EducationalInformation::wherePidAndDegree($input['resumeId'], $educationChecked)->first();
                 if ($ret) {
                     $resume = EducationalInformation::find($ret['id']);
                     $resume->pid = $input['resumeId'];
                     $resume->degree = $educationChecked;
                     $resume->preference = $prefe;
                     $resume->major = $input['major_' . $educationChecked];
                     $resume->gyear = $input['gradyear_' . $educationChecked];
                     $resume->school = $input['school_' . $educationChecked];
                     $resume->board = $input['board_' . $educationChecked];
                     $resume->grade = $input['percentage_' . $educationChecked];
                     $resume->resume_certificate = '';
                     $resume->save();
                 } else {
                     $resume = new EducationalInformation();
                     $resume->pid = $input['resumeId'];
                     $resume->degree = $educationChecked;
                     $resume->preference = $prefe;
                     $resume->major = $input['major_' . $educationChecked];
                     $resume->gyear = $input['gradyear_' . $educationChecked];
                     $resume->school = $input['school_' . $educationChecked];
                     $resume->board = $input['board_' . $educationChecked];
                     $resume->grade = $input['percentage_' . $educationChecked];
                     $resume->resume_certificate = '';
                     $resume->save();
                 }
             }
         }
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
         //}
     }
     if ($input['level'] == 3 && $input['resumeId'] > 0) {
         if (Input::file('exp_certificate')) {
             $exp_certificate = array('file' => Input::file('exp_certificate'), 'extention' => Input::file('exp_certificate')->getClientOriginalExtension());
             $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx');
             $validator = Validator::make($exp_certificate, $rules);
             if ($validator->fails()) {
                 // send back to the page with the input data and errors
                 // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png');
                 Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx');
                 return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
             } else {
                 $exp_certificate = array('exp_certificate' => Input::file('exp_certificate'));
                 $destinationPath = 'upload';
                 $expCertificateExtension = Input::file('exp_certificate')->getClientOriginalExtension();
                 $expCertificateName = rand(11111, 99999) . '_expcertificate' . '.' . $expCertificateExtension;
                 Input::file('exp_certificate')->move($destinationPath, $expCertificateName);
             }
         }
         $ret = WorkInformation::where('pid', $input['resumeId'])->first();
         if ($ret) {
             $resume = WorkInformation::where('pid', $input['resumeId'])->update(['pid' => $input['resumeId'], 'position_title' => $input['position_title'], 'company_name' => $input['company_name'], 'from_date' => $input['from_date'], 'to_date' => isset($input['wpresent']) ? 1 : $input['to_date'], 'experience' => $input['experience'], 'specialization' => $input['specialization'], 'role' => $input['role'], 'country' => $input['country'], 'industry' => isset($input['industry']) ? $input['industry'] : $ret->industry, 'position_level' => isset($input['position_level']) ? $input['position_level'] : $ret->position_level, 'currency' => isset($input['currency']) ? $input['currency'] : $ret->currency, 'salary' => $input['salary'], 'experience_certificate' => isset($expCertificateName) ? $expCertificateName : $ret->experience_certificate]);
         } else {
             $resume = new WorkInformation();
             $resume->pid = $input['resumeId'];
             $resume->position_title = $input['position_title'];
             $resume->company_name = $input['company_name'];
             $resume->experience = $input['experience'];
             $resume->from_date = $input['from_date'];
             $resume->to_date = isset($input['wpresent']) ? 1 : $input['to_date'];
             $resume->specialization = $input['specialization'];
             $resume->role = $input['role'];
             $resume->country = $input['country'];
             $resume->industry = isset($input['industry']) ? $input['industry'] : '';
             $resume->position_level = isset($input['position_level']) ? $input['position_level'] : '';
             $resume->currency = isset($input['currency']) ? $input['currency'] : '';
             $resume->salary = $input['salary'];
             $resume->experience_certificate = isset($expCertificateName) ? $expCertificateName : '';
             $resume->save();
         }
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
     }
     if ($input['level'] == 4 && $input['resumeId'] > 0) {
         $t = $input['skillCount'];
         for ($c = 1; $c <= $t; $c++) {
             if (Input::file('skills_certificate_' . $c)) {
                 $skills_certificate = array('file' => Input::file('skills_certificate_' . $c), 'extention' => Input::file('skills_certificate_' . $c)->getClientOriginalExtension());
                 $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx');
                 $validator = Validator::make($skills_certificate, $rules);
                 if ($validator->fails()) {
                     // send back to the page with the input data and errors
                     // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png');
                     Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx');
                     return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
                 } else {
                     $skill_certificate = array('skills_certificate_' . $c => Input::file('skills_certificate_' . $c));
                     $destinationPath = 'upload';
                     $skillCertificateExtension = Input::file('skills_certificate_' . $c)->getClientOriginalExtension();
                     $skillCertificateName = rand(11111, 99999) . '_skill_certificate' . '.' . $skillCertificateExtension;
                     Input::file('skills_certificate_' . $c)->move($destinationPath, $skillCertificateName);
                 }
             } else {
                 $skillCertificateName = '';
             }
             $ret = SkillsInformation::wherePidAndSkills($input['resumeId'], $input["skill_" . $c])->first();
             if ($ret) {
                 $resume = SkillsInformation::find($ret->id);
                 // $resume->skills = $input["skill_".$c];
                 $resume->proficiency = $input["proficiency_" . $c];
                 if ($skillCertificateName != '') {
                     $resume->skills_certificate = $skillCertificateName;
                 }
                 $resume->save();
             } else {
                 $resume = new SkillsInformation();
                 $resume->pid = $input['resumeId'];
                 $resume->skills = $input["skill_" . $c];
                 $resume->proficiency = $input["proficiency_" . $c];
                 $resume->skills_certificate = isset($skillCertificateName) ? $skillCertificateName : '';
                 $resume->save();
             }
         }
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
     }
     if ($input['level'] == 5 && $input['resumeId'] > 0) {
         //return $input;
         $t = $input['languageCount'];
         for ($c = 1; $c <= $t; $c++) {
             $ret = Language::wherePidAndLanguage($input['resumeId'], $input['language_' . $c])->first();
             if ($ret) {
                 $resume = Language::find($ret->id);
                 $resume->lspoken = $input['lspoken_' . $c];
                 $resume->lwritten = $input['lwritten_' . $c];
                 $resume->save();
             } else {
                 $resume = new Language();
                 $resume->pid = $input['resumeId'];
                 $resume->language = $input['language_' . $c];
                 $resume->lspoken = $input['lspoken_' . $c];
                 $resume->lwritten = $input['lwritten_' . $c];
                 $resume->save();
             }
         }
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
     }
     if ($input['level'] == 6 && $input['resumeId'] > 0) {
         if (Input::file('sdocument')) {
             $sdocument = array('file' => Input::file('sdocument'), 'extention' => Input::file('sdocument')->getClientOriginalExtension());
             $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx');
             $validator = Validator::make($sdocument, $rules);
             if ($validator->fails()) {
                 // send back to the page with the input data and errors
                 // $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png');
                 Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx');
                 return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
             } else {
                 $sdocument = array('sdocument' => Input::file('sdocument'));
                 $destinationPath = 'upload';
                 $sdocumentExtension = Input::file('sdocument')->getClientOriginalExtension();
                 $sdocumentName = rand(11111, 99999) . '_sdocument' . '.' . $sdocumentExtension;
                 Input::file('sdocument')->move($destinationPath, $sdocumentName);
             }
         }
         $ret = AdditionalInformation::where('pid', $input['resumeId'])->first();
         if ($ret) {
             $resume = AdditionalInformation::find($ret->id);
             $resume->sdocument = isset($sdocumentName) ? $sdocumentName : $ret->sdocument;
         } else {
             $resume = new AdditionalInformation();
             $resume->sdocument = isset($sdocumentName) ? $sdocumentName : '';
         }
         $resume->pid = $input['resumeId'];
         $resume->currency = $input['currency'];
         $resume->salary = $input['salary'];
         $resume->preferred_location = $input['prefered_location'];
         $resume->add_information = $input['add_information'];
         $resume->save();
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
     }
     if ($input['level'] == 7 && $input['resumeId'] > 0) {
         if (Input::file('uresume')) {
             $uresume = array('file' => Input::file('uresume'), 'extention' => Input::file('uresume')->getClientOriginalExtension());
             $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:pdf,doc,docx');
             $validator = Validator::make($uresume, $rules);
             if ($validator->fails()) {
                 // send back to the page with the input data and errors
                 $validator->errors()->add('uresume', 'File size must be less than 2MB and only .pdf,.doc,.docx');
                 return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
             } else {
                 $uresume = array('uresume' => Input::file('uresume'));
                 $destinationPath = 'upload';
                 $uresumeExtension = Input::file('uresume')->getClientOriginalExtension();
                 $uresumeName = rand(11111, 99999) . '_CV' . '.' . $uresumeExtension;
                 Input::file('uresume')->move($destinationPath, $uresumeName);
             }
         }
         $ret = UploadInformation::where('pid', $input['resumeId'])->first();
         if ($ret) {
             $resume = UploadInformation::find($ret->id);
             $resume->uresume = isset($uresumeName) ? $uresumeName : $ret->uresume;
         } else {
             $resume = new UploadInformation();
             $resume->uresume = isset($uresumeName) ? $uresumeName : '';
         }
         $resume->pid = $input['resumeId'];
         $resume->save();
         return view('resume.create')->with('id', $input['resumeId'])->with('state', $input['level'] + 1);
         //$resume->
     }
     if ($input['level'] == 8 && $input['resumeId'] > 0) {
         $ret = PrivacyInformation::where('pid', $input['resumeId'])->first();
         if ($ret) {
             $resume = PrivacyInformation::find($ret->id);
         } else {
             $resume = new PrivacyInformation();
         }
         $resume->pid = $input['resumeId'];
         $resume->privacy = $input['privacy'];
         $resume->save();
         Session::flash('message', 'Resume has been created Successfully');
         return Redirect::to('resume');
         // return view('resume.create')->with('id',$input['resumeId'])->with('state',($input['level'] + 1));
         //$resume->
     }
     // if($input['level'] == 9) {
     // return Redirect::to('resume');
     // }
     Session::flash('message', 'Please Fill up Personal Information First!!');
     return view('resume.create')->with('id', 0)->with('state', 1);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     if (Input::file('company_document')) {
         $company_document = array('file' => Input::file('company_document'), 'extention' => Input::file('company_document')->getClientOriginalExtension());
         $rules = array('file' => 'required|max:2048', 'extention' => 'required|In:pdf,doc,docx,jpeg,bmp,png');
         $validator = Validator::make($company_document, $rules);
         if ($validator->fails()) {
             Session::flash('message', 'File must be less than 2Mb and only pdf,doc,docx,jpeg,bmp,png');
             $agentp = DB::table('members')->whereId($id)->first();
             return view('agent.edit')->with('agentp', $agentp);
         } else {
             $destinationPath = 'upload';
             $companyDocumentExtension = Input::file('company_document')->getClientOriginalExtension();
             $companyDocumentName = rand(11111, 99999) . '_comp_docu' . '.' . $companyDocumentExtension;
             Input::file('company_document')->move($destinationPath, $companyDocumentName);
         }
     }
     $update = DB::table('members')->where('id', $id)->update(['name' => $input['name'], 'address' => $input['address'], 'contactNumber' => $input['contactNumber'], 'email' => $input['email']]);
     $ret = DB::table('memberprofile')->where('uid', $id)->first();
     if ($ret) {
         $mpupdate = DB::table('memberprofile')->where('uid', $id)->update(['company_name' => $input['company_name'], 'company_address' => $input['company_address'], 'company_information' => $input['company_information'], 'company_document' => isset($companyDocumentName) ? $companyDocumentName : '']);
     } else {
         $memprofile = new MemberProfile();
         $memprofile->uid = $id;
         $memprofile->company_name = $input['company_name'];
         $memprofile->company_address = $input['company_address'];
         $memprofile->company_information = $input['company_information'];
         $memprofile->company_document = isset($companyDocumentName) ? $companyDocumentName : '';
         $memprofile->save();
     }
     $rethistory = History::whereAction_idAndAction($id, 'Profile Updated')->first();
     if ($rethistory) {
         $history = History::find($rethistory->id);
         $history->action = 'Profile Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     } else {
         $history = new History();
         $history->action_id = $id;
         $history->action = 'Profile Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     }
     Session::flash('message', 'Updated successfully');
     return Redirect::to('home');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $input = $request->input();
     $update = DB::table('demand')->where('id', $id)->update(['title' => $input['title'], 'no_vacancy' => $input['no_vacancy'], 'qualification' => $input['qualification'], 'location' => $input['location'], 'description' => $input['description']]);
     $rethistory = History::whereAction_idAndAction($id, 'Demand Updated')->first();
     if ($rethistory) {
         $history = History::find($rethistory->id);
         $history->action = 'Demand Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     } else {
         $history = new History();
         $history->action_id = $id;
         $history->action = 'Demand Updated';
         $history->user = Auth::user()->name;
         $history->remark = '';
         $history->save();
     }
     Session::flash('message', 'Demand Updated Successfully');
     return \Redirect::to('demand');
 }
Esempio n. 5
0
 public function updateHistory(Request $request)
 {
     History::find($request->input('pk'))->update([$request->input('name') => $request->input('value')]);
 }