QnaController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 QnaController 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. $qnaPage = $this->callApiService->callApi([
  18. 'url' => 'list-type1-page',
  19. 'data' => [
  20. 'QueryVars' => [
  21. 'QueryName' => 'pro:my-page/post-list',
  22. 'SimpleFilter' => "post_code='faq' and mx.status != '0'",
  23. 'SubSimpleFilter' => "image_type = 'thumb'",
  24. 'IsntPagination' => false
  25. ],
  26. 'ListType1Vars' => [
  27. 'OrderBy' => request('sort', 'mx.created_on desc')
  28. ],
  29. 'PageVars' => [
  30. 'Limit' => $limit,
  31. 'Offset' => ($page - 1) * $limit
  32. ]
  33. ]
  34. ]);
  35. // dd($qnaPage);
  36. if ($this->callApiService->verifyApiError($qnaPage)) {
  37. notify()->error($qnaPage['body'], 'Error', 'bottomRight');
  38. return redirect()->back();
  39. }
  40. // dump($qnaPage);
  41. $qnaPage['Page'] = new LengthAwarePaginator($qnaPage['Page'], $qnaPage['PageVars']['QueryCnt'],
  42. $limit, $page, ['path' => request()->url()]);
  43. return view('views.etc.paq', compact('qnaPage'));
  44. }
  45. }