SeminarSignUpService.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Http\Services\Api;
  3. use App\Models\SignupData;
  4. use App\Models\TrackData;
  5. use DB;
  6. use GuzzleHttp\Client;
  7. class SeminarSignUpService
  8. {
  9. protected $signupDb;
  10. protected $trackDataDb;
  11. public function __construct()
  12. {
  13. $this->signupDb = new SignupData();
  14. $this->trackDataDb = new TrackData();
  15. }
  16. public function insertData(
  17. $firstName, $lastName, $companyName, $companyEmail, $backupEmail, $phoneNumber, $country, $trackNo,
  18. $registeredSession, $lunchOptions, $typeOfIndustry, $typeOfJob, $jobTitle, $trackOfInterest, $areaOfInterest, $howToKnowAboutTheEvent,
  19. $consentAcceptEmail, $consentPrivacyPolicy)
  20. {
  21. $this->signupDb
  22. ->insert([
  23. 'firstName' => $firstName,
  24. 'lastName' => $lastName,
  25. 'companyName' => $companyName,
  26. 'companyEmail' => $companyEmail,
  27. 'backupEmail' => $backupEmail,
  28. 'phoneNumber' => $phoneNumber,
  29. 'country' => $country,
  30. 'trackNo' => $trackNo,
  31. 'registeredSession' => $registeredSession,
  32. 'lunchOptions' => $lunchOptions,
  33. 'typeOfIndustry' => $typeOfIndustry,
  34. 'typeOfJob' => $typeOfJob,
  35. 'jobTitle' => $jobTitle,
  36. 'trackOfInterest' => $trackOfInterest,
  37. 'areaOfInterest' => $areaOfInterest,
  38. 'howToKnowAboutTheEvent' => $howToKnowAboutTheEvent,
  39. 'consentAcceptEmail' => $consentAcceptEmail,
  40. 'consentPrivacyPolicy' => $consentPrivacyPolicy,
  41. 'createDate' => date("Y-m-d H:i:s"),
  42. ]);
  43. }
  44. public function overLimitOrNot($trackNo)
  45. {
  46. \Log::info($trackNo);
  47. $nowCount = $this->signupDb
  48. ->where('trackNo', '=', $trackNo)
  49. ->count();
  50. $limit = $this->trackDataDb
  51. ->select('trackLimit')
  52. ->where('trackNo', '=', $trackNo)
  53. ->first();
  54. if ($limit->trackLimit>$nowCount) {
  55. return true;
  56. } else {
  57. return false;
  58. }
  59. }
  60. public function getData()
  61. {
  62. $res = $this->trackDataDb
  63. ->select([
  64. '*'
  65. ])
  66. ->get();
  67. // 整理返回值並返回
  68. return $res;
  69. }
  70. }