Last active
June 18, 2023 16:12
-
-
Save voidvn/7f67e40c3c13b05d19afa12fa07ca5da to your computer and use it in GitHub Desktop.
Fix for saving non-unicode characters in the database json field for Laravel Model Class (saves characters like that \u1234 in normal form)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @throws JsonException | |
*/ | |
protected function asJson($value): bool|string | |
{ | |
return json_encode($value, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment