AdminController.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $active_teachers_list =User::whereIn(
  23. 'status',[1,2,3]
  24. )->where(
  25. 'user_type',2
  26. )->orderBy(
  27. 'id','DESC'
  28. )->get();
  29. $register_student_list =User::where(
  30. 'user_type',1
  31. )->orderBy(
  32. 'id','DESC'
  33. )->get();
  34. $invited_registered_list =User::where(
  35. 'user_type',2
  36. )->whereNotNull(
  37. 'admin_invite_id'
  38. )->orderBy(
  39. 'id','DESC'
  40. )->get();
  41. $landing_wishlist =User::where(
  42. 'user_type',2
  43. )->where(
  44. 'landing_register',1
  45. )->orderBy(
  46. 'id','DESC'
  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. 'active_teachers_list'=>$active_teachers_list,
  57. 'register_student_list'=>$register_student_list ,
  58. 'market_countries'=>$market_countries,
  59. 'refer_users'=>$refer_users,
  60. 'invited_registered_list'=>$invited_registered_list,
  61. 'application'=>$application,
  62. 'landing_wishlist'=>$landing_wishlist
  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. }