| 
				
			 | 
			
			
				@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Storage; 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				 class HealthyPassPortController extends Controller 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				15
			 | 
			
			
				     private $api_header = array(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+    private $tag_set = array(); 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				17
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				17
			 | 
			
				18
			 | 
			
			
				     public function __construct() 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				19
			 | 
			
			
				     { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -27,7 +28,7 @@ class HealthyPassPortController extends Controller 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				28
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				28
			 | 
			
				29
			 | 
			
			
				     public function profile(Request $request){ 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				30
			 | 
			
			
				         $profile = Survey::where('line_user_id',$request->lineUserId)->first(); 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				-        $profile_tag_list = $profile->getTagList(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+        return response()->json(["data" => $profile] ); 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				32
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				33
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				33
			 | 
			
				34
			 | 
			
			
				     /** 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -46,7 +47,17 @@ class HealthyPassPortController extends Controller 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				47
			 | 
			
			
				         $healthNickname = $request->healthNickname; //暱稱 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				48
			 | 
			
			
				         $healthGender = $request->healthGender; //性別 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				49
			 | 
			
			
				         $healthGenderRole = $request->healthGenderRole;//性別 male or female 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+         
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+        $survey_fill_content = ["healthAction" => $healthAction,  
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+                                "healthTopic" => $healthTopic, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+                                "healthStatus" => $healthStatus, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+                                "healthAdapt" => $healthAdapt, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+                                "healthThought" => $healthThought, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+                                "healthAge" => $healthAge, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+                                "healthGender" => $healthGender, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+        ]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+         
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+        //準備將填寫內容過API寫入 botbonnie 後台 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				61
			 | 
			
			
				         $buildActions = []; 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				62
			 | 
			
			
				         array_push($buildActions, $this->buildActionsRequest("addTag", $healthAction)); 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				63
			 | 
			
			
				         array_push($buildActions, $this->buildActionsRequest("addTag", $healthTopic)); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -55,7 +66,7 @@ class HealthyPassPortController extends Controller 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				66
			 | 
			
			
				         array_push($buildActions, $this->buildActionsRequest("addTag", $healthThought)); 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				67
			 | 
			
			
				         array_push($buildActions, $this->buildActionsRequest("addTag", $healthAge)); 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				68
			 | 
			
			
				         array_push($buildActions, $this->buildActionsRequest("addTag", $healthGender)); 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-        if($healthGenderRole != "")array_push($buildActions, $this->buildActionsRequest("saveParams", $healthGenderRole, "demographics", "gender")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+        if($healthGenderRole != "")array_push($buildActions, $this->buildActionsRequest("saveParams", $healthGenderRole, "demographics", "gender"));        
			 | 
		
	
		
			
			| 
				59
			 | 
			
				70
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				60
			 | 
			
				71
			 | 
			
			
				         $statusCode = $this->botActionsSend($lineUserId,$buildActions); 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				72
			 | 
			
			
				         if($statusCode == 200){ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -64,6 +75,14 @@ class HealthyPassPortController extends Controller 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				75
			 | 
			
			
				             array_push($buildActions, $this->buildActionsRequest("addTag", config("botApi.doneSurvey"))); 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				76
			 | 
			
			
				             array_push($buildActions, $this->buildActionsRequest("setMenu", config("botApi.setMenuDoneSurvey"))); 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				77
			 | 
			
			
				             $this->botActionsSend($lineUserId,$buildActions); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+            //儲存填寫資料 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+            $survey_data = new Survey(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+            $survey_data->line_user_id = $lineUserId; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+            $survey_data->head_sticker = $headSticker; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+            $survey_data->nickname = $healthNickname; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+            $survey_data->filler_content = json_encode($survey_fill_content); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+            $survey_data->save(); 
			 | 
		
	
		
			
			| 
				67
			 | 
			
				86
			 | 
			
			
				             return  response()->json(["result" => 'successed']); 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				87
			 | 
			
			
				         }else{ 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				88
			 | 
			
			
				             return response()->json(["result" => 'failed'] ); 
			 |