浏览代码

20220905 把 dd 和 log 拿掉 / phone 加正規式驗證 / 按語言區分通知信內容

LuluFJ.Ho 2 年前
父节点
当前提交
fb84f716d3

+ 1
- 0
app/Exceptions/Handler.php 查看文件

@@ -57,6 +57,7 @@ class Handler extends ExceptionHandler
57 57
 
58 58
     public function handleApiException(Throwable $exception)
59 59
     { 
60
+        // dd($exception);
60 61
         // Route Not Found 404
61 62
         if ($exception instanceof RouteNotFoundException) {
62 63
             return $this->apiExceptionResponse($exception, Response::HTTP_NOT_FOUND, config('response-message.router_failed'));

+ 66
- 6
app/Http/Controllers/Api/SeminarSignUpController.php 查看文件

@@ -22,15 +22,21 @@ class SeminarSignUpController extends ApiController
22 22
     // save data to db
23 23
     public function insertData(StoreRequest $request)
24 24
     {
25
-        \Log::info(print_r($request->all(),true));
26 25
         $trackNo = $request->input('trackNo', '');
27
-        $firstName = $this->safeEncrypt($request->input('firstName', ''), 'arm');
26
+        $lang = substr($trackNo, 0, 2);
27
+        $firstName_orig = $request->input('firstName', '');
28
+        $firstName = $this->safeEncrypt($firstName_orig, 'arm');
29
+
28 30
         $lastName = $this->safeEncrypt($request->input('lastName', ''), 'arm');
29 31
         $companyName = $this->safeEncrypt($request->input('companyName', ''), 'arm');
30
-        $companyEmail = $this->safeEncrypt($request->input('companyEmail', ''), 'arm');
32
+
33
+        $companyEmail_orig = $request->input('companyEmail', '');
34
+        $companyEmail = $this->safeEncrypt($companyEmail_orig, 'arm');
31 35
         
32 36
         $backupEmail = $request->input('backupEmail', '');
33 37
         if (!is_null($backupEmail)) {
38
+        
39
+            $backupEmail_orig = $request->input('backupEmail', '');
34 40
             $backupEmail = $this->safeEncrypt($backupEmail, 'arm');
35 41
         }
36 42
 
@@ -48,7 +54,6 @@ class SeminarSignUpController extends ApiController
48 54
         $consentPrivacyPolicy = $request->input('consentPrivacyPolicy', '');
49 55
         
50 56
         $overOrNot = $this->seminarSignUpSv->overLimitOrNot($trackNo);
51
-        \Log::info($overOrNot);
52 57
 
53 58
         if ($overOrNot) {
54 59
 
@@ -73,6 +78,17 @@ class SeminarSignUpController extends ApiController
73 78
                 $consentPrivacyPolicy,
74 79
             );
75 80
             $res = '報名成功';
81
+
82
+            if ($lang=='TW') {
83
+                $this->mailToUser_TW($firstName_orig, $companyEmail_orig, $backupEmail_orig);
84
+            } elseif ($lang=='JP') {
85
+                $this->mailToUser_JP($firstName_orig, $companyEmail_orig, $backupEmail_orig);
86
+            } elseif ($lang=='KR') {
87
+                $this->mailToUser_KR($firstName_orig, $companyEmail_orig, $backupEmail_orig);
88
+            } else {
89
+                $this->mailToUser_EN($firstName_orig, $companyEmail_orig, $backupEmail_orig);
90
+            }
91
+            
76 92
         } else {
77 93
 
78 94
             $res = '已達報名上限';
@@ -80,14 +96,12 @@ class SeminarSignUpController extends ApiController
80 96
         $data = [
81 97
             'res' => $res,
82 98
         ];
83
-        \Log::info(print_r($res,true));
84 99
         
85 100
         return $this->apiResponse($data);
86 101
     }
87 102
 
88 103
     public function getData()
89 104
     {
90
-        
91 105
         $list = $this->seminarSignUpSv->getData();
92 106
         
93 107
         $data = [
@@ -153,4 +167,50 @@ class SeminarSignUpController extends ApiController
153 167
         return base64_decode(join('', $strArr));
154 168
     }
155 169
     
170
+    public function mailToUser_TW(string $firstName='', string $companyEmail='', string $backupEmail='')
171
+    {
172
+        $data = array('name'=>$firstName);
173
+
174
+        \Mail::send(['text'=>'mailTW'], $data, function($message) use ($companyEmail, $firstName, $backupEmail) {
175
+            $message->to($companyEmail, $firstName)->subject('報名成功');       // Registration is complete
176
+            $message->cc($backupEmail, $firstName)->subject('報名成功');       // Registration is complete
177
+            $message->from('no-reply@erapr.com.tw','Arm Tech Symposia 2');
178
+        });
179
+    }
180
+
181
+    public function mailToUser_JP(string $firstName='', string $companyEmail='', string $backupEmail='')
182
+    {
183
+        $data = array('name'=>$firstName);
184
+
185
+        \Mail::send(['text'=>'mailJP'], $data, function($message) use ($companyEmail, $firstName, $backupEmail) {
186
+            $message->to($companyEmail, $firstName)->subject('登録完了');
187
+            $message->cc($backupEmail, $backupEmail)->subject('登録完了');
188
+            $message->from('no-reply@erapr.com.tw','Arm Tech Symposia 2');
189
+        });
190
+    }
191
+
192
+    public function mailToUser_KR(string $firstName='', string $companyEmail='', string $backupEmail='')
193
+    {
194
+        $data = array('name'=>$firstName);
195
+
196
+        \Mail::send(['text'=>'mailKR'], $data, function($message) use ($companyEmail, $firstName, $backupEmail) {
197
+            $message->to($companyEmail, $firstName)->subject('등록이 완료되었습니다');
198
+            $message->cc($backupEmail, $firstName)->subject('등록이 완료되었습니다');
199
+            $message->from('no-reply@erapr.com.tw','Arm Tech Symposia 2');
200
+        });
201
+    }
202
+    
203
+    public function mailToUser_EN(string $firstName='', string $companyEmail='', string $backupEmail='')
204
+    {
205
+        $data = array('name'=>$firstName);
206
+
207
+        \Mail::send(['text'=>'mailEN'], $data, function($message) use ($companyEmail, $firstName, $backupEmail) {
208
+            $message->to($companyEmail, $firstName)->subject('Registration is complete');
209
+            $message->cc($backupEmail, $firstName)->subject('Registration is complete');
210
+            $message->from('no-reply@erapr.com.tw','Arm Tech Symposia 2');
211
+        });
212
+    }
213
+
156 214
 }
215
+
216
+

+ 6
- 5
app/Http/Requests/Api/SeminarSignUp/StoreRequest.php 查看文件

@@ -14,7 +14,7 @@ class StoreRequest extends FormRequest
14 14
             'companyName'   => 'required',
15 15
             'companyEmail'  => 'required|email',
16 16
             'backupEmail'   => 'sometimes|nullable|email',
17
-            'phoneNumber'    => 'required',
17
+            'phoneNumber'    => 'required|regex:/((?=(09))[0-9]{10})$/',
18 18
             'country'   => 'required',
19 19
             // 'registeredSession'   => 'required',    // 如果選擇台灣track則必填
20 20
             // 'lunchOptions'   => 'required',         // 如果選擇台灣track則必填
@@ -33,14 +33,15 @@ class StoreRequest extends FormRequest
33 33
     public function messages(): array
34 34
     {
35 35
         return [
36
-            'trackNo.required'  => 'column [trackNo] is required.',
36
+            /*'trackNo.required'  => 'column [trackNo] is required.',
37 37
             'firstName.required'    => 'column [firstName] is required.',
38 38
             'lastName.required'     => 'column [lastName] is required.',
39 39
             'companyName.required'  => 'column [companyName] is required.',
40 40
             'companyEmail.required' => 'column [companyEmail] is required.',
41
-            'companyEmail.email'    => 'column [companyEmail] format error',
42
-            'backupEmail.email'     => 'column [backupEmail] format error',
41
+            'companyEmail.email'    => 'column [companyEmail] is format error',
42
+            'backupEmail.email'     => 'column [backupEmail] is format error',
43 43
             'phoneNumber.required'  => 'column [phoneNumber] is required.',
44
+            'phoneNumber.regex'  => 'column [phoneNumber] is format error.',
44 45
             'country.required'  => 'column [country] is required.',
45 46
             // 'registeredSession.required'  => 'column [registeredSession] is required.',     // 如果選擇台灣track則必填
46 47
             // 'lunchOptions.required'  => 'column [lunchOptions] is required.',     // 如果選擇台灣track則必填
@@ -51,7 +52,7 @@ class StoreRequest extends FormRequest
51 52
             'areaOfInterest.required'  => 'column [areaOfInterest] is required.',
52 53
             'howToKnowAboutTheEvent.required'  => 'column [howToKnowAboutTheEvent] is required.',
53 54
             'consentAcceptEmail.required'  => 'column [consentAcceptEmail] is required.',
54
-            'consentPrivacyPolicy.required'  => 'column [consentPrivacyPolicy] is required.',
55
+            'consentPrivacyPolicy.required'  => 'column [consentPrivacyPolicy] is required.',*/
55 56
         ];
56 57
     }
57 58
 }

+ 0
- 1
app/Http/Services/Api/SeminarSignUpService.php 查看文件

@@ -53,7 +53,6 @@ class SeminarSignUpService
53 53
     
54 54
     public function overLimitOrNot($trackNo)
55 55
     {
56
-        \Log::info($trackNo);
57 56
 
58 57
         $nowCount = $this->signupDb
59 58
             ->where('trackNo', '=', $trackNo)

+ 3
- 0
resources/views/mailEN.blade.php 查看文件

@@ -0,0 +1,3 @@
1
+Hi {{ $name }}
2
+
3
+Registration is complete

+ 3
- 0
resources/views/mailJP.blade.php 查看文件

@@ -0,0 +1,3 @@
1
+ こんにちは {{ $name }}
2
+
3
+登録完了

+ 3
- 0
resources/views/mailKR.blade.php 查看文件

@@ -0,0 +1,3 @@
1
+안녕하십니까 {{ $name }}
2
+
3
+등록이 완료되었습니다

+ 3
- 0
resources/views/mailTW.blade.php 查看文件

@@ -0,0 +1,3 @@
1
+{{ $name }} 您好
2
+
3
+已完成報名

+ 1
- 0
routes/api.php 查看文件

@@ -8,6 +8,7 @@ use App\Http\Controllers\Api\SeminarSignUpController;
8 8
 Route::prefix('signup')->group(function () {
9 9
     Route::post('/insertData', [SeminarSignUpController::class, 'insertData']);
10 10
     Route::get('/getData', [SeminarSignUpController::class, 'getData']);
11
+    Route::get('/mail', [SeminarSignUpController::class, 'mailToUser']);
11 12
 });
12 13
 
13 14