AdminController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use App\User;
  6. use App\Country;
  7. use App\Models\MarketCountry;
  8. use App\Models\ReferUser;
  9. use App\StudentProposal;
  10. use App\Models\University;
  11. use Auth;
  12. use Mail;
  13. use Session;
  14. use Hash;
  15. class AdminController extends Controller
  16. {
  17. public function __construct(){
  18. $this->middleware('admin');
  19. }
  20. public function dashboard()
  21. {
  22. $admin = Auth::guard('admin')->user();
  23. $register_active_teachers_list =User::where(
  24. 'apply_status',1
  25. )->where(
  26. 'sign_up',1
  27. )->where(
  28. 'user_type',2
  29. )->orderBy(
  30. 'registered_date','DESC'
  31. )->get();
  32. $pending_student_list =User::where(
  33. 'user_type',1
  34. )->where(
  35. 'sign_up',0
  36. )->where(
  37. 'register_type',4
  38. )->orderBy(
  39. 'id','DESC'
  40. )->get();
  41. $register_student_list =User::where(
  42. 'user_type',1
  43. )->where(
  44. 'sign_up',1
  45. )->orderBy(
  46. 'id','DESC'
  47. )->get();
  48. $invited_registered_list =User::where(
  49. 'user_type',2
  50. )->whereNotNull(
  51. 'admin_invite_id'
  52. )->where(
  53. 'register_type',1 //1=teacher invitation
  54. )->orderBy(
  55. 'id','DESC'
  56. )->get();
  57. $landing_wishlist =User::where(
  58. 'user_type',2
  59. )->where(
  60. 'register_type',2 // 2=teacher landing
  61. )->orderBy(
  62. 'id','DESC'
  63. )->get();
  64. $market_countries = MarketCountry::where(
  65. 'status', 1
  66. )->select(
  67. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
  68. )->orderBy('sort')->get();
  69. $student_refer_friend_list =User::where(
  70. 'register_type',6 // 6 = student refer a friend for a proposal
  71. )->where(
  72. 'user_type',1
  73. )->orderBy('id','DESC')->get();
  74. $application = StudentProposal::where(
  75. 'proposal_submit_status',1
  76. )->orderBy('id','DESC')->get();
  77. $data =[
  78. 'register_active_teachers_list'=>$register_active_teachers_list,
  79. 'register_student_list'=>$register_student_list ,
  80. 'market_countries'=>$market_countries,
  81. 'refer_users'=>$student_refer_friend_list,
  82. 'invited_registered_list'=>$invited_registered_list,
  83. 'application'=>$application,
  84. 'landing_wishlist'=>$landing_wishlist,
  85. 'pending_student_list'=>$pending_student_list,
  86. 'admin'=>$admin
  87. ];
  88. return view('admin.admin_profile',$data);
  89. }
  90. public function load_country_list($text){
  91. $selected = MarketCountry::pluck('country_id')->toArray();
  92. if($text == '0'){
  93. $countries = Country::where('status', 1)->paginate(10);
  94. }else{
  95. $countries = Country::where('status', 1)->where('name','like', '%'.$text.'%')->paginate(10);
  96. }
  97. return view('admin.loadCountry', compact('countries','selected'));
  98. }
  99. public function destination_wise_university(Request $request){
  100. $universities = University::where(
  101. 'country_id',$request->country_id
  102. )->orderBy(
  103. 'name'
  104. )->select(
  105. 'id','name'
  106. )->get();
  107. return [
  108. 'msg'=>'Destination wise university data',
  109. 'data'=>[
  110. 'universities'=>$universities
  111. ]
  112. ];
  113. }
  114. }