callApiService = $callApiService; } public function index($siseType, $area=null, $memberbershipname=null) { // siseType별로 title 변수 생성 switch ($siseType) { case 'golf': $title_dir = "골프"; $title = "골프회원권 시세"; break; case 'condo': $title_dir = "콘도"; $title = "콘도회원권 시세"; break; default: $title_dir = "휘트니스"; $title = "휘트니스회원권 시세"; } $query = "post_type_id = 59 and pc5='$siseType'"; if($area){ if($area != 'all'){ // switch ($area) { // case '123': // $query .= " and pc2='1' or pc2='2' or pc2='3'"; // break; // case '45': // $query .= " and pc2='4' or pc2='5'"; // break; // default: // $query .= " and pc2='$area'"; // } $query .= " and pc2='$area'"; } } if($memberbershipname){ $query .= " and postTitle like '%$memberbershipname%'"; } $limit = (int)request('limit', 12); $page = (int)request('page', 1); // api 호출 request $siseList = $this->callApiService->callApi([ 'url' => 'post-page', 'data' => [ 'PageVars' => [ 'Query' => $query, 'Desc' => 'created_on', 'Limit' => $limit, 'Offset' => ($page - 1) * $limit ] ] ]); // dd($siseList); // 등락 계산 if (isset($siseList['Page']) && !empty($siseList['Page'])) { foreach ($siseList['Page'] as &$sise) { if (isset($sise['Pc3'], $sise['Pc4'])) { $sise['fluctuation'] = (float)$sise['Pc3'] - (float)$sise['Pc4']; } else { $sise['fluctuation'] = 0; } } } if ($this->callApiService->verifyApiError($siseList)) { notify()->error($siseList['body'], 'Error', 'bottomRight'); return redirect()->back(); } // pagenation $totalcnt = $siseList['PageVars']['QueryCnt']; $siseItems['Page'] = new LengthAwarePaginator( $siseList['Page'], $totalcnt, $limit, $page, ['path' => request()->url()] ); return view('views.page.sise', compact('siseList', 'siseItems', 'title', "title_dir", "siseType", "area")); } }