SubContentController.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use \App\Helpers\PageSL;
  6. use App\Models\University;
  7. use App\Models\MarketCountry;
  8. use App\Models\Department;
  9. use App\Models\ResearchInterest;
  10. use App\Models\Requirement;
  11. use App\Models\Publication;
  12. use App\StudentProposal;
  13. use App\AcademicLevel;
  14. use App\Institution;
  15. use App\Proposal;
  16. use App\Score;
  17. use App\Workexperience;
  18. use App\User;
  19. use Auth;
  20. class SubContentController extends Controller
  21. {
  22. public function get(Request $req, $name){
  23. $carbon=new \Carbon\Carbon;
  24. $data=[
  25. 'carbon'=>$carbon,
  26. 'name'=>$name
  27. ];
  28. if($name=="load_market_countries"){
  29. $user=Auth::guard('admin')->user();
  30. $data['market_countries'] = MarketCountry::where(
  31. 'status', 1
  32. )->select(
  33. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
  34. )->orderBy('sort')->get();
  35. }elseif($name=='country_wise_university'){
  36. $user=Auth::guard('admin')->user();
  37. $data['universities'] =University::orderBy('name','ASC')->get();
  38. }elseif($name=="load_profile_info"){
  39. $tuser=Auth::guard('teacher')->user();
  40. $data['tuser'] =$tuser;
  41. $data['students'] = StudentProposal::where('teacher_id',$tuser->id)->get();
  42. }elseif($name=="load_department"){
  43. $data['departments'] =Department::where('status',1)->orderBy('name','ASC')->get();
  44. }elseif($name=="load_research_interest"){
  45. $tuser=Auth::guard('teacher')->user();
  46. $data['resarch'] =ResearchInterest::where('teacher_id',$tuser->id)->orderBy('id','DESC')->get();
  47. }elseif($name=="edit_university_load"){
  48. $user=Auth::guard('admin')->user();
  49. $data['edit_data'] =University::find($req->edit_id);
  50. $data['market_countries'] = MarketCountry::where(
  51. 'status', 1
  52. )->select(
  53. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
  54. )->orderBy('sort')->get();
  55. }elseif($name=="edit_department_form"){
  56. $data['edit_dept'] =Department::find($req->dep_id);
  57. }elseif($name=="load_ref_no_available_info"){
  58. if($req->teacher_ref_no){
  59. $data['teacher'] =User::where(
  60. 'ref_no',$req->teacher_ref_no
  61. )->where(
  62. 'is_available',1
  63. )->first();
  64. }
  65. }elseif($name=="document_required_load"){
  66. $proposal_details = StudentProposal::find($req->id);
  67. $data['proposal_details'] =$proposal_details;
  68. $data['requirements'] = Requirement::where('std_proposal_id',$proposal_details->id)->get();
  69. }elseif($name=="upload_document_required"){
  70. $data['requirements'] = Requirement::find($req->req_id);
  71. $std_pro_id =$data['requirements'];
  72. $data['proposal_details'] = StudentProposal::where('id',$std_pro_id->std_proposal_id)->first();
  73. }elseif($name=="edit_proposal"){
  74. $data['proposal'] =Proposal::find($req->p_id);
  75. $data['departments'] =Department::where('status',1)->orderBy('name','ASC')->get();
  76. }elseif($name=="register_pending_teacher_load"){
  77. $data['register_teachers_list'] =User::whereIn(
  78. 'apply_status', [0,2,3] // 0 = Pending; 2= In active ; 3= Suspend
  79. )->where(
  80. 'user_type',2
  81. )->where(
  82. 'sign_up',1
  83. )->orderBy(
  84. 'id','DESC'
  85. )->get();
  86. }elseif($name=="edit_teacher_load"){
  87. $user=Auth::guard('admin')->user();
  88. $data['departments'] =Department::where('status',1)->orderBy('name','ASC')->get();
  89. $data['universities'] =University::orderBy('name','ASC')->get();
  90. $data['market_countries'] = MarketCountry::where(
  91. 'status', 1
  92. )->select(
  93. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as name')
  94. )->orderBy('name')->get();
  95. info($data['market_countries']);
  96. $data['edit_data'] =User::find($req->edit_id);
  97. }elseif($name=="edit_research_form"){
  98. $data['edit_research'] =ResearchInterest::find($req->res_id);
  99. }elseif($name=="publication_list_load"){
  100. $student=Auth::user();
  101. $data['publications'] = Publication::where(
  102. 'student_id',$student->id
  103. )->orderBy(
  104. 'id','DESC'
  105. )->get();
  106. $data['is_freez_profile'] = User::where(
  107. 'id',Auth::user()->id
  108. )->where(
  109. 'freez_profile','!=',0
  110. )->exists();
  111. }elseif($name=="edit_publication_load"){
  112. $data['edit_data']=Publication::find($req->edit_id);
  113. }elseif($name=="education_history_load"){
  114. $data['institution']= Institution::where(
  115. 'student_id',Auth::user()->id
  116. )->orderBy(
  117. 'id','DESC'
  118. )->get();
  119. $data['is_freez_profile'] = User::where(
  120. 'id',Auth::user()->id
  121. )->where(
  122. 'freez_profile','!=',0
  123. )->exists();
  124. }elseif($name=="edit_education_load"){
  125. $data['edit_data']=Institution::find($req->edit_id);
  126. $data['academic_level']= AcademicLevel::orderBy('name','ASC')->get();
  127. $data['passingyear']= range((int)date('Y')-20,(int)date('Y'));
  128. }elseif($name=="english_languge_proficiency_load"){
  129. $student=Auth::user();
  130. $data['score']= Score::where(
  131. 'student_id',$student->id
  132. )->orderBy(
  133. 'id','ASC'
  134. )->get();
  135. $data['is_freez_profile'] = User::where(
  136. 'id',Auth::user()->id
  137. )->where(
  138. 'freez_profile','!=',0
  139. )->exists();
  140. }elseif($name=="edit_english_languge_proficiency_form"){
  141. $student=Auth::user();
  142. $data['edit_data']= Score::find($req->edit_id);
  143. }elseif($name=="work_experience_load"){
  144. $data['work_experience']= Workexperience::where(
  145. 'student_id',Auth::user()->id
  146. )->orderBy('id','DESC')->get();
  147. $data['is_freez_profile'] = User::where(
  148. 'id',Auth::user()->id
  149. )->where(
  150. 'freez_profile','!=',0
  151. )->exists();
  152. }elseif($name=="edit_work_experience_form"){
  153. $student=Auth::user();
  154. $data['edit_data']= Workexperience::find($req->edit_id);
  155. $data['years']= range((int)date('Y')-20,(int)date('Y'));
  156. }elseif($name=="edit_feedback_msg_form"){
  157. $data['edit'] =StudentProposal::find($req->std_propsal_id);
  158. }else $name='default';
  159. //$data['page_sl']=new PageSL($data['chapter_details']);
  160. return view("admin.sub_contents.{$name}", $data);
  161. }
  162. }