EventController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace Themes\kbgolf\pro\app\Http\Controllers\MyPage;
  3. use App\Http\Controllers\Controller;
  4. use App\Services\CallApiService;
  5. use Illuminate\Pagination\LengthAwarePaginator;
  6. class EventController extends Controller
  7. {
  8. private $callApiService;
  9. public function __construct(CallApiService $callApiService)
  10. {
  11. $this->callApiService = $callApiService;
  12. }
  13. public function list()
  14. {
  15. $limit = (int)request('limit', 12);
  16. $page = (int)request('page', 1);
  17. $eventPage = $this->callApiService->callApi([
  18. 'url' => 'list-type1-page',
  19. 'data' => [
  20. 'QueryVars' => [
  21. 'QueryName' => 'pro:my-page/event-list',
  22. 'SimpleFilter' => "mx.status != '0'",
  23. 'SubSimpleFilter' => "image_type = 'middle'",
  24. 'IsntPagination' => false
  25. ],
  26. 'ListType1Vars' => [
  27. 'OrderBy' => request('sort', 'mx.status asc')
  28. ],
  29. 'PageVars' => [
  30. 'Limit' => $limit,
  31. 'Offset' => ($page - 1) * $limit
  32. ]
  33. ]
  34. ]);
  35. if ($this->callApiService->verifyApiError($eventPage)) {
  36. notify()->error($eventPage['body'], 'Error', 'bottomRight');
  37. return redirect()->back();
  38. }
  39. // dump($eventPage);
  40. $eventPage['Page'] = new LengthAwarePaginator($eventPage['Page'], $eventPage['PageVars']['QueryCnt'],
  41. $limit, $page, ['path' => request()->url()]);
  42. return view('views.my-page.event-list', compact('eventPage'))->with('codeTitle', [
  43. "status('post-event')",
  44. ]);
  45. }
  46. public function show($id)
  47. {
  48. $listType1Book = $this->callApiService->callApi([
  49. 'url' => 'list-type1-book',
  50. 'data' => [
  51. 'Book' => [
  52. [
  53. 'QueryVars' => [
  54. 'QueryName' => 'pro:my-page/event-details',
  55. 'SimpleFilter' => "mx.id = $id",
  56. 'IsntPagination' => true,
  57. ],
  58. 'PageVars' => [
  59. 'Limit' => 1
  60. ]
  61. ],
  62. [
  63. 'QueryVars' => [
  64. 'QueryName' => 'pro:my-page/post-details-prenext',
  65. 'SimpleFilter' => "mx.id = (select max(id) from pro_post where id < ${id} and post_type_id = 3) and mx.status != '0'",
  66. 'SubSimpleFilter' => "",
  67. 'IsntPagination' => true,
  68. ],
  69. 'PageVars' => [
  70. 'Limit' => 1
  71. ]
  72. ],
  73. [
  74. 'QueryVars' => [
  75. 'QueryName' => 'pro:my-page/post-details-prenext',
  76. 'SimpleFilter' => "mx.id = (select min(id) from pro_post where id > ${id} and post_type_id = 3) and mx.status != '0'",
  77. 'SubSimpleFilter' => "",
  78. 'IsntPagination' => true,
  79. ],
  80. 'PageVars' => [
  81. 'Limit' => 1
  82. ]
  83. ],
  84. ]
  85. ]
  86. ]);
  87. if ($this->callApiService->verifyApiError($listType1Book)) {
  88. notify()->error($listType1Book['body'], 'Error', 'bottomRight');
  89. return redirect()->back();
  90. }
  91. // dump($listType1Book);
  92. return view('views.my-page.event-details', compact('listType1Book'))->with('codeTitle', [
  93. "status('post-event')",
  94. ]);
  95. }
  96. }