Advertisement
Guest User

ApplicantController

a guest
Jan 16th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. public function store(Request $request)
  2. {
  3. session_start();
  4. if(isset($_POST["captcha"]) && $_POST["captcha"]!="" && $_SESSION["code"]==$_POST["captcha"])
  5. {
  6. //
  7.  
  8. $this->validate($request, [
  9. 'name' => 'required|max:255',
  10. 'sex' => 'required',
  11. 'marital_status' => 'required',
  12. 'date_of_birth' => 'required|date',
  13. 'photo' => 'required|dimensions:min_width=300,min_height=300,max_width=700,max_height=700|mimes:jpeg,jpg,png,JPG,JPEG,png,gif|max:80KB',
  14. 'fathers_name' => 'required',
  15. 'mothers_name' => 'required',
  16. 'spouses_name' => 'required',
  17. 'nationality' => 'required',
  18. 'present_add' => 'required',
  19. 'permanent_add' => 'required',
  20. 'district' => 'required',
  21. 'bank_draft_no' => 'required',
  22. 'resume' => 'required|mimes:pdf,docx,doc|max:700KB',
  23. 'contact_no' => 'required|numeric',
  24. 'captcha' => 'required',
  25. ]);
  26.  
  27. }else{
  28. return Redirect::back()->withErrors(['Code is not Matching']);
  29. }
  30.  
  31.  
  32. $applicant = new Applicant();
  33. $applicant['name'] = $request->input('name');
  34. $applicant['sex'] = $request->input('sex');
  35. $applicant['marital_status'] = $request->input('marital_status');
  36. $applicant['date_of_birth'] = $request->input('date_of_birth');
  37. $applicant['email'] = $request->input('email');
  38. $applicant['fathers_name'] = $request->input('fathers_name');
  39. $applicant['mothers_name'] = $request->input('mothers_name');
  40. $applicant['spouses_name'] = $request->input('spouses_name');
  41. $applicant['nationality'] = $request->input('nationality');
  42. $applicant['present_add'] = $request->input('present_add');
  43. $applicant['permanent_add'] = $request->input('permanent_add');
  44. $applicant['bank_draft_no'] = $request->input('bank_draft_no');
  45. $applicant['ref_no'] = $request->input('ref_no');
  46. $applicant['quota'] = $request->input('quota');
  47. $applicant['district'] = $request->input('district');
  48. $applicant['resume'] = $request->input('resume');
  49. $applicant['contact_no'] = $request->input('contact_no');
  50.  
  51. if ($request->hasFile('photo')) {
  52.  
  53. $file = array('photo' => Input::file('photo'));
  54. $destinationPath = 'file/'; // upload path
  55. $extension = Input::file('photo')->getClientOriginalExtension();
  56. $fileName = rand(11111,99999).'.'.$extension; // renaming image
  57. Input::file('photo')->move($destinationPath, $fileName);
  58. $applicant->photo = $fileName;
  59. }else{
  60. echo "Please Add Your Photo!";
  61. }
  62. if ($request->hasFile('resume')) {
  63.  
  64. $file = array('resume' => Input::file('resume'));
  65. $destinationPath = 'file/'; // upload path
  66. $extension = Input::file('resume')->getClientOriginalExtension();
  67. $fileName = rand(11111,99999).'.'.$extension; // renaming file
  68. Input::file('resume')->move($destinationPath, $fileName);
  69. $applicant->resume = $fileName;
  70. }else{
  71. echo "Please Add Your Resume!";
  72. }
  73.  
  74. $job = Job::find($id);
  75. DB::table('applicants')->insert(['job_id' => $job->id]);
  76.  
  77. $applicant->save();
  78. $id = $applicant->id;
  79.  
  80.  
  81. \Session::flash('flash_message','Application has been successfully submitted.');
  82. return Redirect::to('career/confirmation/'.$id);
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement