SeminarSignUpService.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Http\Services\Web;
  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($name, $email, $mobile, $trackId)
  17. {
  18. $this->signupDb
  19. ->insert([
  20. 'name' => $name,
  21. 'email' => $email,
  22. 'mobile' => $mobile,
  23. 'trackId' => $trackId,
  24. 'createDate' => date("Y-m-d H:i:s"),
  25. ]);
  26. }
  27. public function overLimitOrNot($trackId)
  28. {
  29. $nowCount = $this->signupDb
  30. ->where('trackId', '=', $trackId)
  31. ->count();
  32. $limit = $this->trackDataDb
  33. ->select('trackLimit')
  34. ->where('trackNo', '=', $trackId)
  35. ->first();
  36. if ($limit->trackLimit>$nowCount) {
  37. return true;
  38. } else {
  39. return false;
  40. }
  41. }
  42. public function getData()
  43. {
  44. $res = $this->trackDataDb
  45. ->select([
  46. '*'
  47. ])
  48. ->get();
  49. // 整理返回值並返回
  50. return $res;
  51. }
  52. }