user(); if (! $admin instanceof AdminUser) { return ApiResponse::error( trans('admin.unauthenticated', [], $request->lotteryLocale()), ErrorCode::AdminUnauthenticated->value, null, 401, ); } try { $row = $this->adjustments->apply( $pool, $admin, (int) $request->validated('amount_delta'), (string) $request->validated('reason'), $request, ); } catch (\RuntimeException $e) { return ApiMessage::runtimeErrorResponse($request, $e, ErrorCode::ClientHttpError->value, 422); } $pool->refresh(); return ApiResponse::success([ 'adjustment' => $this->adjustmentRow($row), 'pool' => [ 'id' => (int) $pool->id, 'currency_code' => $pool->currency_code, 'current_amount' => (int) $pool->current_amount, 'updated_at' => $pool->updated_at?->toIso8601String(), ], ]); } }