signupDb=new SignupData(); } public function getList(&$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue, $keyword, $createDateStart, $createDateFinal) { // 調用資料庫(或者其他業務邏輯) $res = $this->signupDb ->select('*'); if ($keyword){ $res->where('firstName', $keyword) ->orWhere('lastName', $keyword) ->orWhere('companyName', $keyword) ->orWhere('companyEmail', $keyword) ->orWhere('backupEmail', $keyword) ->orWhere('phoneNumber', $keyword) ->orWhere('country', $keyword) ->orWhere('trackNo', $keyword) ->orWhere('typeOfIndustry', $keyword) ->orWhere('typeOfJob', $keyword) ->orWhere('jobTitle', $keyword); } $res->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) { $res = $this->signupDb ->select('*'); if ($keyword != ""){ $res->where('firstName', $keyword) ->orWhere('lastName', $keyword) ->orWhere('companyName', $keyword) ->orWhere('companyEmail', $keyword) ->orWhere('backupEmail', $keyword) ->orWhere('phoneNumber', $keyword) ->orWhere('country', $keyword) ->orWhere('trackNo', $keyword) ->orWhere('typeOfIndustry', $keyword) ->orWhere('typeOfJob', $keyword) ->orWhere('jobTitle', $keyword); } $res = $this->signupDb ->get() ->toArray(); // 整理返回值並返回 return $res; } }