TeacherHomeController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\User;
  5. use App\StudentProposal;
  6. use App\Models\Department;
  7. use App\Models\ReferUser;
  8. use App\Models\University;
  9. use App\Models\Requirement;
  10. use App\Institution;
  11. use App\Workexperience;
  12. use Auth;
  13. use Input;
  14. class TeacherHomeController extends Controller
  15. {
  16. public function __construct()
  17. {
  18. $this->middleware('teacher');
  19. }
  20. public function dashboard(Request $request)
  21. { $user = Auth::guard('teacher')->user();
  22. $students = StudentProposal::where(
  23. 'teacher_id',$user->id
  24. )->where(
  25. 'proposal_submit_status',1
  26. )->get();
  27. $departments =Department::where('status',1)->orderBy('name','ASC')->get();
  28. // $refer_users =ReferUser::where('teacher_id',$user->id)->orderBy('id','DESC')->get();
  29. $refer_users =User::where(
  30. 'wishlist_teacher_id',$user->id
  31. )->whereIn(
  32. 'register_type',[3,4] // 3=q_form; 4= wishlist
  33. )->orderBy('id','DESC')->get();
  34. $universities =University::orderBy('name','ASC')->get();
  35. return view('supervisor.dashboard',compact('students','user','departments','refer_users','universities'));
  36. }
  37. public function applications(){
  38. $user = Auth::guard('teacher')->user();
  39. $students = StudentProposal::where(
  40. 'teacher_id',$user->id
  41. )->where(
  42. 'proposal_submit_status',1
  43. )->get();
  44. return view('supervisor.applications',compact('user','students'));
  45. }
  46. public function search(Request $request)
  47. {
  48. $input = Input::all();
  49. $request = (object) $input;
  50. $carbon=new \Carbon\Carbon;
  51. $teacher = Auth::guard('teacher')->user();
  52. $students = StudentProposal::where(
  53. 'proposal_submit_status',1
  54. )->where(
  55. 'teacher_id',$teacher->id
  56. )->orderBy('id','desc');
  57. if ($request->apply_ref) {
  58. $students->where('student_apply_ref',$request->apply_ref);
  59. }
  60. if (isset($input['proposal_status'])) {
  61. $students->where('proposal_status',$input['proposal_status']);
  62. }
  63. if($request->submitted_date){
  64. $date_array = explode("to",$request->submitted_date);
  65. $from_date = date('d-m-Y', strtotime($date_array[0]));
  66. $to_date = date('d-m-Y', strtotime($date_array[1]));
  67. $start_date=$carbon->parse($from_date)->toDateString();
  68. $end_date=$carbon->parse($to_date)->toDateString();
  69. $students->whereRaw("DATE(submitted_date) >= ? AND DATE(submitted_date) <= ?", [$start_date, $end_date]);
  70. }
  71. if($request->preffered_start_date){
  72. $date_array = explode("to",$request->preffered_start_date);
  73. $from_month_year = date('m-Y', strtotime($date_array[0])); //01-06-2023
  74. $to_month_year = date('m-Y', strtotime($date_array[1]));//31-07-2023
  75. $start_date=$carbon->parse('01-'.$from_month_year)->toDateString();
  76. $end_date=$carbon->parse('01-'.$to_month_year)->toDateString();
  77. $students->whereRaw("DATE(preferred_start_date) >= ? AND DATE(preferred_start_date) <= ?", [$start_date, $end_date]);
  78. }
  79. $data=[
  80. 'students' => $students->get(),
  81. 'user'=> Auth::guard('teacher')->user(),
  82. ];
  83. return view('supervisor.load_application',$data);
  84. }
  85. public function wishlist(){
  86. $user = Auth::guard('teacher')->user();
  87. $refer_users =User::where(
  88. 'wishlist_teacher_id',$user->id
  89. )->whereIn(
  90. 'register_type',[3,4] // 3=q_form; 4= wishlist
  91. )->orderBy('id','DESC')->get();
  92. return view('supervisor.wishlist',compact('user','refer_users'));
  93. }
  94. public function explore(){
  95. $user = Auth::guard('teacher')->user();
  96. return view('supervisor.explore');
  97. }
  98. public function my_account(){
  99. $user = Auth::guard('teacher')->user();
  100. $universities =University::orderBy('name','ASC')->get();
  101. $departments =Department::where('status',1)->orderBy('name','ASC')->get();
  102. return view('supervisor.my_account',compact('user','departments','universities'));
  103. }
  104. public function student_proposal_details($hash){
  105. $user = Auth::guard('teacher')->user();
  106. $hashids=new \Hashids\Hashids('application', 25);
  107. $hash_ids=$hashids->decode($hash);
  108. if(empty($hash_ids[0])) abort(404);
  109. $proposal_details = StudentProposal::find($hash_ids[0]);
  110. $education_history =Institution::where(
  111. 'student_id',$proposal_details->student_id
  112. )->orderBy('id','desc')->get();
  113. $experience =Workexperience::where(
  114. 'student_id',$proposal_details->student_id
  115. )->get();
  116. if(isset($experience)){
  117. $work_experince =[];
  118. foreach($experience as $key=>$row){
  119. array_push($work_experince,$row->start_date);
  120. array_push($work_experince,$row->end_date);
  121. }
  122. $start_date = current($work_experince);
  123. $end_date = end($work_experince);
  124. }
  125. $doc_info =Requirement::where(
  126. 'std_proposal_id',$proposal_details->id
  127. )->get();
  128. return view('supervisor.student_proposal_details',compact('hash_ids','proposal_details','education_history','start_date','end_date','doc_info'));
  129. }
  130. }