Skip to content

Instantly share code, notes, and snippets.

@voidvn
Last active June 18, 2023 16:12
Show Gist options
  • Save voidvn/7f67e40c3c13b05d19afa12fa07ca5da to your computer and use it in GitHub Desktop.
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)
/**
* @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