signupDb=new SignupData(); } public function getList(&$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue, $keyword, $trackNo, $createDateStart, $createDateFinal) { // 調用資料庫(或者其他業務邏輯) $res = $this->signupDb ->select('*'); $res->where('firstName', $keyword) ->orWhere('lastName', $keyword) ->orWhere('companyName', $keyword) ->orWhere('companyEmail', $keyword) ->orWhere('backupEmail', $keyword) ->orWhere('phoneNumber', $keyword); $res->where('trackNo','LIKE', $trackNo.'%') ->where('createDate', '>', $createDateStart) ->where('createDate', '<', $createDateFinal); // 取總筆數 $cnt = $res->count(); // 排序 $res = $res ->orderByRaw((int)$orderColumn . ' ' . $orderDir); // 分頁 $res = $res ->skip($start)->take($length); // 實際取資料 $result = $res ->get() ->toArray(); // 整理返回值並返回 return $result; } public function getExportList($keyword, $trackNo, $createDateStart, $createDateFinal) { \Log::info('keyword: '.$keyword); \Log::info('trackNo: '.$trackNo); \Log::info('createDateStart: '.$createDateStart); \Log::info('createDateFinal: '.$createDateFinal); $res = $this->signupDb ->select('*') ->where('trackNo','LIKE', $trackNo.'%') ->where('firstName', $keyword) ->orWhere('lastName', $keyword) ->orWhere('companyName', $keyword) ->orWhere('companyEmail', $keyword) ->orWhere('backupEmail', $keyword) ->orWhere('phoneNumber', $keyword) ->where('createDate', '>', $createDateStart) ->where('createDate', '<', $createDateFinal); $res = $this->signupDb ->get() ->toArray(); \Log::info(print_r($res,true)); // 整理返回值並返回 return $res; } }