AdminController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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=invitation
  42. )->orderBy(
  43. 'id','DESC'
  44. )->get();
  45. $landing_wishlist =User::where(
  46. 'user_type',2
  47. )->where(
  48. 'register_type',2 // 2=landing wishlist
  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 =ReferUser::orderBy('id','DESC')->get();
  58. $application = StudentProposal::orderBy('id','DESC')->get();
  59. $data =[
  60. 'register_active_teachers_list'=>$register_active_teachers_list,
  61. 'register_student_list'=>$register_student_list ,
  62. 'market_countries'=>$market_countries,
  63. 'refer_users'=>$refer_users,
  64. 'invited_registered_list'=>$invited_registered_list,
  65. 'application'=>$application,
  66. 'landing_wishlist'=>$landing_wishlist
  67. ];
  68. return view('admin.admin_profile',$data);
  69. }
  70. public function load_country_list($text){
  71. $selected = MarketCountry::pluck('country_id')->toArray();
  72. if($text == '0'){
  73. $countries = Country::where('status', 1)->paginate(10);
  74. }else{
  75. $countries = Country::where('status', 1)->where('name','like', '%'.$text.'%')->paginate(10);
  76. }
  77. return view('admin.loadCountry', compact('countries','selected'));
  78. }
  79. }