input('_jwt_user_id'); $userType = $request->input('_jwt_user_type'); $page = (int) $request->input('page', 1); $limit = min((int) $request->input('limit', 20), 50); if ($userType === 'driver') { $notifications = DB::connection('primary')->table('notificationCaptain') ->where('driverID', $userId) ->orderBy('dateCreated', 'desc') ->skip(($page - 1) * $limit)->take($limit) ->get(); } else { $notifications = DB::connection('primary')->table('notifications') ->where('passenger_id', $userId) ->orderBy('created_at', 'desc') ->skip(($page - 1) * $limit)->take($limit) ->get(); } return response()->json(['status' => 'success', 'data' => $notifications]); } /** PUT /v2/notifications/{id}/read */ public function markRead(Request $request, int $id): JsonResponse { $userType = $request->input('_jwt_user_type'); $table = $userType === 'driver' ? 'notificationCaptain' : 'notifications'; DB::connection('primary')->table($table) ->where('id', $id) ->update(['isShown' => 'true']); return response()->json(['status' => 'success']); } }