AdminController.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_teachers_list =User::where(
  23. 'status',0
  24. )->where(
  25. 'user_type',2
  26. )->orderBy(
  27. 'name','ASC'
  28. )->get();
  29. $active_teachers_list =User::whereIn(
  30. 'status',[1,2,3]
  31. )->where(
  32. 'user_type',2
  33. )->orderBy(
  34. 'name','ASC'
  35. )->get();
  36. $register_student_list =User::where(
  37. 'user_type',1
  38. )->orderBy(
  39. 'name','ASC'
  40. )->get();
  41. $invited_registered_list =User::where(
  42. 'user_type',2
  43. )->whereNotNull(
  44. 'admin_invite_id'
  45. )->orderBy(
  46. 'name','ASC'
  47. )->get();
  48. $market_countries = MarketCountry::where(
  49. 'status', 1
  50. )->select(
  51. 'market_countries.*', \DB::raw('(SELECT name FROM countries WHERE market_countries.country_id = countries.id ) as sort')
  52. )->orderBy('sort')->get();
  53. $refer_users =ReferUser::orderBy('id','DESC')->get();
  54. $application = StudentProposal::orderBy('id','DESC')->get();
  55. $data =[
  56. 'register_teachers_list'=>$register_teachers_list ,
  57. 'active_teachers_list'=>$active_teachers_list,
  58. 'register_student_list'=>$register_student_list ,
  59. 'market_countries'=>$market_countries,
  60. 'refer_users'=>$refer_users,
  61. 'invited_registered_list'=>$invited_registered_list,
  62. 'application'=>$application
  63. ];
  64. return view('admin.admin_profile',$data);
  65. }
  66. public function load_country_list($text){
  67. $selected = MarketCountry::pluck('country_id')->toArray();
  68. if($text == '0'){
  69. $countries = Country::where('status', 1)->paginate(10);
  70. }else{
  71. $countries = Country::where('status', 1)->where('name','like', '%'.$text.'%')->paginate(10);
  72. }
  73. return view('admin.loadCountry', compact('countries','selected'));
  74. }
  75. }