| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | 
							- <?php
 - 
 - namespace App\Http\Services\Api;
 - 
 - use App\Models\SignupData;
 - use App\Models\TrackData;
 - 
 - use DB;
 - use GuzzleHttp\Client;
 - 
 - class SeminarSignUpService
 - {
 -     protected $signupDb;
 -     protected $trackDataDb;
 -     
 -     public function __construct()
 -     {
 -         $this->signupDb = new SignupData();
 -         $this->trackDataDb = new TrackData();
 -         
 -     }
 -     
 -     public function insertData(
 -         $firstName, $lastName, $companyName, $companyEmail, $backupEmail, $phoneNumber, $country, $trackNo, 
 -         $registeredSession, $lunchOptions, $typeOfIndustry, $typeOfJob, $jobTitle, $trackOfInterest, $areaOfInterest, 
 -         $howToKnowAboutTheEvent, $consentAcceptEmail, $consentPrivacyPolicy)
 -     {
 -         
 -         $this->signupDb
 -             ->insert([
 -                 'firstName'     => $firstName,
 -                 'lastName'      => $lastName,
 -                 'companyName'   => $companyName,
 -                 'companyEmail'  => $companyEmail,
 -                 'backupEmail'   => $backupEmail,
 -                 'phoneNumber'   => $phoneNumber,
 -                 'country'       => $country,
 -                 'trackNo'       => $trackNo,
 -                 'registeredSession' => $registeredSession,
 -                 'lunchOptions'      => $lunchOptions,
 -                 'typeOfIndustry'    => $typeOfIndustry,
 -                 'typeOfJob'     => $typeOfJob,
 -                 'jobTitle'      => $jobTitle,
 -                 'trackOfInterest'   => $trackOfInterest,
 -                 'areaOfInterest'    => $areaOfInterest,
 -                 'howToKnowAboutTheEvent'    => $howToKnowAboutTheEvent,
 -                 'consentAcceptEmail'    => $consentAcceptEmail,
 -                 'consentPrivacyPolicy'    => $consentPrivacyPolicy,
 -                 'createDate'    => date("Y-m-d H:i:s"),
 -             ]);
 -         
 -     }
 -     
 -     public function overLimitOrNot($trackNo)
 -     {
 -         $nowCount = 0;
 - 
 -         $nowCount = $this->signupDb
 -             ->where('trackNo', '=', $trackNo)
 -             ->count();
 -         
 -         $limit = $this->trackDataDb
 -             ->select('trackLimit')
 -             ->where('trackNo', '=', $trackNo)
 -             ->first();
 -         
 -         if ($limit->trackLimit>$nowCount) {
 -             return true;
 -         } else {
 -             return false;
 -         }
 -     }
 -     
 -     public function duplicatedOrNot($trackNo, $companyEmail, $phoneNumber)
 -     {
 -         $cnt = 0;
 - 
 -         $cnt = $this->signupDb
 -             ->where('trackNo', '=', $trackNo)
 -             ->where('companyEmail', '=', $companyEmail)
 -             ->where('phoneNumber', '=', $phoneNumber)
 -             ->count();
 -         
 -         \Log::info($cnt);
 - 
 -         if ($cnt==0) {
 -             return true;
 -         } else {
 -             return false;
 -         }
 -     }
 -     
 -     public function getData()
 -     {
 -         
 -         $res = $this->trackDataDb
 -             ->select([
 -                 'trackData.*',
 -                 \DB::raw('trackLimit-count(signupData.id) as remain')
 -                 
 -             ])
 -             ->leftJoin('signupData', 'trackData.trackNo', '=', 'signupData.trackNo')
 -             ->groupBy('trackData.trackNo')
 -             ->get();
 - 
 -         // 整理返回值並返回
 -         return $res;
 - 
 -     }
 - 
 - }
 
 
  |