maa3520 il y a 2 ans
Parent
commit
b992976dad

+ 3 - 3
app/Http/Controllers/CheckInController.php

@@ -71,13 +71,13 @@ class CheckInController extends Controller
     {
         //
         $checkIn = $request->activity_id ?
-            CheckIn::where('user_id', '=', $request->id)->where('activity_id', '=', $request->activity_id)->first()
-            : CheckIn::where('user_id', '=', $request->id)->first();
+            CheckIn::where('user_id', '=', $request->user_id)->where('activity_id', '=', $request->activity_id)->first()
+            : CheckIn::where('user_id', '=', $request->user_id)->first();
 
         $department = Department::where('department_id', '=', $checkIn->department_id)->first();
         $checkIn->department = $department->department_name ?? '暫無部門';
         $response = [
-            'checkIn' => $checkIn,
+            'user' => $checkIn,
         ];
         return response($response, 201);
     }

+ 4 - 3
resources/js/src/views/lottery/CheckIn.vue

@@ -36,7 +36,7 @@
 								報到狀態
 							</b-card-text>
 							<b-card-text>
-								{{ checkin_status(user.checkIn) }}
+								{{ checkin_status(user.is_checked_in) }}
 							</b-card-text>
 						</div>
 					</b-col>
@@ -197,7 +197,7 @@ export default {
 			}
 		},
 		searchData() {
-			useJwt.postData('/api/user/show', { 'id': this.input, 'activity_id': this.$route.params.activity_id }).then(response => {
+			useJwt.postData('/api/checkin/show', { 'user_id': this.input, 'activity_id': this.$route.params.activity_id }).then(response => {
 				console.log(response.data.user);
 				this.user = response.data.user;
 				this.input = "";
@@ -212,6 +212,7 @@ export default {
 		},
 		showToast(variant) {
 			useJwt.postData('/api/check_in/update', { 'user_id': this.user.user_id }).then(response => {
+				console.log(response.data)
 				this.$toast({
 					component: ToastificationContent,
 					props: {
@@ -221,7 +222,7 @@ export default {
 						variant,
 					},
 				})
-				this.user.checkIn = 1;
+				this.user.is_checked_in = 1;
 			}).catch(error => {
 				console.log(error)
 			});

+ 3 - 2
routes/api.php

@@ -103,7 +103,8 @@ Route::middleware(['auth:sanctum', 'abilities:Admin'])->group(function () {
     Route::post('/check_in/update', [CheckInController::class, 'update']);
     Route::post('/check_in/check_out', [CheckInController::class, 'check_out']);
     Route::post('/check_in/draw', [CheckInController::class, 'draw_user_when_check_in']);
-
+    Route::post('/checkin/show', [CheckInController::class, 'show']);
+    
     // Draw
     Route::post('/draw/draw', [DrawController::class, 'draw']);
 
@@ -113,7 +114,7 @@ Route::middleware(['auth:sanctum', 'abilities:Admin'])->group(function () {
     Route::post('/recipient/claim', [RecipientsController::class, 'claim']);
     Route::post('/recipient/isClaimed', [RecipientsController::class, 'isClaimed']);
 
-    Route::post('/checkin/show', [CheckInController::class, 'show']);
+    
 });
 Route::post('/user/index', [UserController::class, 'index']);
 Route::post('/department/index', [DepartmentController::class, 'index']);