| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 | 
							- <?php
 - 
 - namespace App\Http\Services\Backend\DataManagement;
 - 
 - use App\Http\Services\ConstDef\GeneralConst;
 - use App\Models\TrackData;
 - use DB;
 - use Log;
 - use PhpOffice\PhpSpreadsheet\IOFactory;
 - use PhpOffice\PhpSpreadsheet\Spreadsheet;
 - 
 - class TrackManagementService
 - {
 -     
 -     // 相關私有 model 調用器宣告
 -     private $signupDb;
 -     public function __construct()
 -     {
 -         // 建構 model 調用器
 -         $this->trackDataDb = new TrackData();
 - 
 -     }
 -     public function getList(&$cnt = 0, $orderColumn, $orderDir, $start, $length, $searchValue, $keyword)
 -     {
 -         // 調用資料庫(或者其他業務邏輯)
 -         $res = $this->trackDataDb
 -             ->select('*')
 -             ->where('trackNo', 'like', '%'.$keyword.'%')
 -             ->orWhere('trackTitle', 'like', '%'.$keyword.'%');
 -             
 -         // 取總筆數
 -         $cnt = $res->count();
 -         // 排序
 -         $res = $res
 -             ->orderByRaw((int)$orderColumn . ' ' . $orderDir);
 -         // 分頁
 -         $res = $res
 -             ->skip($start)->take($length);
 -         // 實際取資料
 -         $result = $res
 -             ->get()
 -             ->toArray();
 -         
 -         // 整理返回值並返回
 -         return $result;
 -     }
 - 
 -     public function getReferral()
 -     {
 -         $res=$this->referralDB->select(["id","name","referral"])->get();
 -         if(!empty($res))
 -         {
 -             $res=$res->toArray();
 -         }
 -         return $res;
 -     }
 -     public function getTrackDataById($id)
 -     {
 -         $res=$this->trackDataDb
 -             ->select('*')
 -             ->where("id",$id)
 -             ->first();
 - 
 -         if(!empty($res))
 -         {
 -             $res=$res->toArray();
 -         }
 -         return $res;
 -     }
 -     public function getReferralByReferral($referral)
 -     {
 -         return $this->referralDB->where('referral', $referral)->first();
 -     }
 -     public function modifyReferral($id,$name,$referral,$richmenuId,$orlCode=0)
 -     {
 -         $res=$this->referralDB->where("id",$id)->update(["name"=>$name,"richmenuId"=>$richmenuId,"orlCode"=>$orlCode]);
 -         return $res;
 -     }
 -     public function modifyReferralPicsee($id,$picseeCode,$picseeUrl,$qRCode)
 -     {
 -         $res=$this->referralDB->where("id",$id)->update(["picseeCode"=>$picseeCode,"shortUrl"=>$picseeUrl,"qRCode"=>$qRCode]);
 -         return $res;
 -     }
 -     public function modifyPicseeCntAndTime($id,$picseeCnt,$last_call)
 -     {
 -         $res=$this->referralDB->where("id",$id)->update(["picseeCnt"=>$picseeCnt,"last_call"=>$last_call]);
 -         return $res;
 -     }
 -     
 -     public function insert($trackNo, $trackTitle, $trackLimit)
 -     {
 -         
 -         $this->trackDataDb
 -             ->insert([
 -                 'trackNo'       => $trackNo,
 -                 'trackTitle'    => $trackTitle,
 -                 'trackLimit'    => $trackLimit,
 -                 'createDate'    => date("Y-m-d H:i:s"),
 -             ]);
 - 
 -         return ;
 -     }
 -     
 -     public function store($id, $trackNo, $trackTitle, $trackLimit)
 -     {
 -         $this->trackDataDb
 -                 ->where('id', $id)
 -                 ->update([
 -                     'trackNo'       => $trackNo,
 -                     'trackTitle'    => $trackTitle,
 -                     'trackLimit'    => $trackLimit,
 -                     'updateDate'    => date("Y-m-d H:i:s"),
 -                 ]);
 -                 
 -         return $id;
 -     }
 - 
 -     public function deleteDataById($id)
 -     {
 -         // 取得參數
 -         // 調用資料庫(或者其他業務邏輯)
 -         $res = $this->trackDataDb
 -             ->where('id', $id)
 -             ->delete();
 -         
 -         // 整理返回值並返回
 -         return $res;
 -     }
 - 
 -     public function getExportList($keyword)
 -     {
 -         $res = $this->signupDb
 -             ->select('*')
 -             // 過濾搜尋條件
 -             ->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('registeredSession', $keyword)
 -             // ->orWhere('lunchOptions', $keyword)
 -             ->orWhere('typeOfIndustry', $keyword)
 -             ->orWhere('typeOfJob', $keyword)
 -             ->orWhere('jobTitle', $keyword)
 -             ->get()
 -             ->toArray();
 -         
 -         // 整理返回值並返回
 -         return $res;
 -     }
 - 
 - }
 
 
  |