AdminController.php 2.8 KB

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