$registrar->register( $request->string('username')->toString(), $request->string('email')->toString(), $request->string('password')->toString(), ); $account = config('moonwell.registration.require_invite_code') ? $inviteCodes->redeemForRegistration( $request->string('invite_code')->toString(), $request->string('username')->toString(), $register, ) : $register(); } catch (DuplicateGameAccountException|InviteCodeException $exception) { return response()->json([ 'message' => $exception->getMessage(), 'errors' => [ $exception->field => [$exception->getMessage()], ], ], 422); } catch (Throwable $exception) { report($exception); return response()->json([ 'message' => 'Не удалось создать аккаунт. Попробуй снова позже.', ], 500); } return response()->json([ 'message' => 'Игровой аккаунт успешно создан.', 'account' => [ 'id' => $account['id'], 'username' => $account['username'], ], ], 201); } }