AjaxController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use Illuminate\Http\Request;
  4. use App\Http\Controllers\Controller;
  5. use App\Models\Admin;
  6. use Auth;
  7. use Mail;
  8. use Session;
  9. use DB;
  10. class AjaxController extends Controller
  11. {
  12. public function __construct()
  13. {
  14. $this->middleware('admin');
  15. $this->api_base_url = apiUrl();
  16. }
  17. public function ajaxGET(Request $request, $name){
  18. $loggedin = Auth::guard('admin')->user();
  19. if($name == 'sams_institutes'){
  20. $destination = $request->destination;
  21. $type = $request->type;
  22. $data = getApiRequest($this->api_base_url.'api/sams-institutes/v1/get-institutes?destination='.$destination.'&type='.$type);
  23. return $data;
  24. }elseif($name == 'sams_levels'){
  25. $institute = $request->institute;
  26. $group = $request->group;
  27. $data = getApiRequest($this->api_base_url.'api/sams-institutes/v1/get-levels?institute='.$institute.'&group='.$group);
  28. return $data;
  29. }elseif($name == 'sams_campuses'){
  30. $institute = $request->institute;
  31. $data = getApiRequest($this->api_base_url.'api/sams-institutes/v1/get-campuses?institute='.$institute);
  32. return $data;
  33. }elseif($name == 'sams_intakes'){
  34. $institute = $request->institute;
  35. $level = $request->level;
  36. $data = getApiRequest($this->api_base_url.'api/sams-institutes/v1/get-intakes?institute='.$institute.'&level='.$level);
  37. return $data;
  38. }else{
  39. return response([
  40. 'msg'=>'Wrong Request! nothing to load.'
  41. ], 403);
  42. }
  43. return view('admin.admins.list',compact('admins'));
  44. }
  45. }