AdminController.php 3.2 KB

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