diff --git a/src/Illuminate/Support/Js.php b/src/Illuminate/Support/Js.php index 69e9a7626122..c924d1c83262 100644 --- a/src/Illuminate/Support/Js.php +++ b/src/Illuminate/Support/Js.php @@ -74,7 +74,7 @@ protected function convertDataToJavaScriptExpression($data, $flags = 0, $depth = $data = $data->value; } - $json = $this->jsonEncode($data, $flags, $depth); + $json = static::encode($data, $flags, $depth); if (is_string($data)) { return "'".substr($json, 1, -1)."'"; @@ -93,7 +93,7 @@ protected function convertDataToJavaScriptExpression($data, $flags = 0, $depth = * * @throws \JsonException */ - protected function jsonEncode($data, $flags = 0, $depth = 512) + public static function encode($data, $flags = 0, $depth = 512) { if ($data instanceof Jsonable) { return $data->toJson($flags | static::REQUIRED_FLAGS);