OMEGA\ericyh.huang 1 年之前
父節點
當前提交
6c45656fd7
共有 1 個檔案被更改,包括 5 行新增2 行删除
  1. 5
    2
      src/be/app/Http/Controllers/HealthyPassPortController.php

+ 5
- 2
src/be/app/Http/Controllers/HealthyPassPortController.php 查看文件

@@ -41,7 +41,7 @@ class HealthyPassPortController extends Controller
41 41
      */
42 42
     public function post(Request $request){
43 43
         $lineUserId = $request->lineUserId; //line UID
44
-        $headSticker = $request->headSticker; //頭貼
44
+        $headSticker = $request->headSticker ?? ""; //頭貼
45 45
         $healthAction = $request->healthAction; //平常你有什麼健康行動(複選)
46 46
         $healthTopic = $request->healthTopic; //你對什麼健康話題有興趣(複選)
47 47
         $healthStatus = $request->healthStatus; //你覺得自己的身體狀況如何
@@ -81,7 +81,10 @@ class HealthyPassPortController extends Controller
81 81
             $this->botActionsSend($lineUserId,$buildActions);
82 82
 
83 83
             //儲存填寫資料
84
-            $survey_data = new Survey();
84
+            $survey_data = Survey::where('line_user_id',$lineUserId)->first();
85
+            if(empty($survey_data->id)){
86
+                $survey_data = new Survey();
87
+            }
85 88
             $survey_data->line_user_id = $lineUserId;
86 89
             $survey_data->head_sticker = $headSticker;
87 90
             $survey_data->nickname = $healthNickname;