123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers\Page;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Illuminate\Pagination\LengthAwarePaginator;
- use Illuminate\Http\Request;
- class SiseController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->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"));
- }
- }
|