AdminController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. 'id','DESC'
  30. )->get();
  31. $register_student_list =User::where(
  32. 'user_type',1
  33. )->orderBy(
  34. 'id','DESC'
  35. )->get();
  36. $invited_registered_list =User::where(
  37. 'user_type',2
  38. )->whereNotNull(
  39. 'admin_invite_id'
  40. )->where(
  41. 'register_type',1 //1=teacher invitation
  42. )->orderBy(
  43. 'id','DESC'
  44. )->get();
  45. $landing_wishlist =User::where(
  46. 'user_type',2
  47. )->where(
  48. 'register_type',2 // 2=teacher landing
  49. )->orderBy(
  50. 'id','DESC'
  51. )->get();
  52. $market_countries = MarketCountry::where(
  53. 'status', 1
  54. )->select(
  55. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
  56. )->orderBy('sort')->get();
  57. $refer_users =User::whereIn(
  58. 'register_type',[3,4] // 3 = QForm ; 4 = Student Wishlist or Refer
  59. )->where(
  60. 'user_type',2
  61. )->orderBy('id','DESC')->get();
  62. $application = StudentProposal::orderBy('id','DESC')->get();
  63. $data =[
  64. 'register_active_teachers_list'=>$register_active_teachers_list,
  65. 'register_student_list'=>$register_student_list ,
  66. 'market_countries'=>$market_countries,
  67. 'refer_users'=>$refer_users,
  68. 'invited_registered_list'=>$invited_registered_list,
  69. 'application'=>$application,
  70. 'landing_wishlist'=>$landing_wishlist
  71. ];
  72. return view('admin.admin_profile',$data);
  73. }
  74. public function load_country_list($text){
  75. $selected = MarketCountry::pluck('country_id')->toArray();
  76. if($text == '0'){
  77. $countries = Country::where('status', 1)->paginate(10);
  78. }else{
  79. $countries = Country::where('status', 1)->where('name','like', '%'.$text.'%')->paginate(10);
  80. }
  81. return view('admin.loadCountry', compact('countries','selected'));
  82. }
  83. }