EducationController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Http\Request;
  4. use App\Http\Requests;
  5. use App\Http\Controllers\Controller;
  6. use App\Models\Employee;
  7. use App\Models\EmployeeEducation;
  8. use App\Models\EmployeeDocument;
  9. use App\Models\EducationLevel;
  10. use App\Models\DocumentType;
  11. class EducationController extends Controller
  12. {
  13. public function index()
  14. {
  15. $data['title'] = "Education Level";
  16. $data['all'] = EducationLevel::orderBy('level_name','ASC')->get();
  17. return view('admin.education_level.index',$data);
  18. }
  19. /**
  20. * Show the form for creating a new resource.
  21. *
  22. * @return \Illuminate\Http\Response
  23. */
  24. public function create()
  25. {
  26. $data['title'] = "Education Level Create";
  27. return view('admin.education_level.add',$data);
  28. }
  29. /**
  30. * Store a newly created resource in storage.
  31. *
  32. * @param \Illuminate\Http\Request $request
  33. * @return \Illuminate\Http\Response
  34. */
  35. public function store(Request $request)
  36. {
  37. $this->validate($request,[
  38. 'level_name' => 'required'
  39. ]);
  40. $user_id = \Auth::user()->id;
  41. $edu_level = new EducationLevel;
  42. $edu_level->level_name = $request->level_name;
  43. $edu_level->added_by = $user_id;
  44. $edu_level->status = 1;
  45. $edu_level->save();
  46. return redirect()->back()->with('msg','Data Insert Successful!');
  47. }
  48. public function edit($id)
  49. {
  50. $data['title'] = "Education Level Edit";
  51. $data['edu_level'] = EducationLevel::find($id);
  52. return view('admin.education_level.edit',$data);
  53. }
  54. /**
  55. * Update the specified resource in storage.
  56. *
  57. * @param \Illuminate\Http\Request $request
  58. * @param int $id
  59. * @return \Illuminate\Http\Response
  60. */
  61. public function update(Request $request, $id)
  62. {
  63. $this->validate($request,[
  64. 'level_name' => 'required'
  65. ]);
  66. $user_id = \Auth::user()->id;
  67. $edu_level = EducationLevel::find($id);
  68. $edu_level->level_name = $request->level_name;
  69. $edu_level->updated_by = $user_id;
  70. $edu_level->save();
  71. return redirect('admin/education_level')->with('msg','Data Update Successful!');
  72. }
  73. /**
  74. * Remove the specified resource from storage.
  75. *
  76. * @param int $id
  77. * @return \Illuminate\Http\Response
  78. */
  79. public function destroy($id)
  80. {
  81. EducationLevel::whereId($id)->delete();
  82. return redirect('admin/education_level')->with('msg','Successfully Deleted!');
  83. }
  84. public function statusUpdate($id)
  85. {
  86. $edu_info = EducationLevel::find($id);
  87. if($edu_info->status == 0){
  88. $edu_info->status = 1;
  89. $status = 'published';
  90. }else{
  91. $edu_info->status = 0;
  92. $status = 'unpublished';
  93. }
  94. $user_id = \Auth::user()->id;
  95. $edu_info->approved_by = $user_id;
  96. $edu_info->update();
  97. }
  98. }