CascadeController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request as Req;
  5. use Request;
  6. /**
  7. * 级联关系
  8. */
  9. class CascadeController extends Controller {
  10. /**
  11. * 获取级联关系
  12. *
  13. * @access public
  14. * @param mixed $req 传入参数 rank等级 id当前ID gameType球类型
  15. * @return array JsonString
  16. */
  17. public function index(Req $req) {
  18. $rank = isset($req->rank) ? $req->rank : 0;
  19. $id = isset($req->id) ? $req->id : 0;
  20. $gameType = isset($req->gameType) ? $req->gameType : 0;
  21. // 赛事种类获取
  22. $gameTypeModel = new \App\Models\StGameType();
  23. $getGameTypeSelect = ['id', 'game_name', 'game_code'];
  24. $getGameTypeWhere['status'] = 1;
  25. $getGameTypeWhere['id'] = $gameType;
  26. $getGameType = $gameTypeModel -> getGameType($getGameTypeSelect, $getGameTypeWhere);
  27. // 获取级联数据
  28. $cascadeModel = new \App\Models\Cascade();
  29. $result = [];
  30. switch ($rank) {
  31. // 级联关系[0洲,1国家,2联赛,3球队]
  32. case 0:
  33. $getResultSelect = ['id', 'title', 'source'];
  34. $result = $cascadeModel -> getArea($getResultSelect);
  35. break;
  36. case 1:
  37. $getResultSelect = ['country_id', 'name_chinese', 'name_english', 'country_ico', 'country_area', 'id', 'source'];
  38. $getResultWhere['country_area'] = $id;
  39. $result = $cascadeModel -> getCountry($getResultSelect, $getResultWhere, $getGameType[0]['game_code'], $gameType);
  40. break;
  41. case 2:
  42. $getResultSelect = ['name_chinese', 'name_english', 'kind', 'league_pic', 'country_id', 'area_id', 'id', 'lg_id'];
  43. $getResultWhere['country_id'] = $id;
  44. $result = $cascadeModel -> league($getResultSelect, $getResultWhere, $getGameType[0]['game_code']);
  45. break;
  46. case 3:
  47. $getResultSelect = ['id', 'home_team', 'guest_team', 'lg_id'];
  48. $getResultWhere['lg_id'] = $id;
  49. $result = $cascadeModel -> getCompetition($getResultSelect, $getResultWhere, $getGameType[0]['game_code']);
  50. break;
  51. }
  52. return json_encode($result);
  53. }
  54. }
  55. ?>