I am developing a web admin panel using Laravel Nova.
I'm getting an issue about Japanese character saving to Database.
My environment is as follows:
- Laravel Version: 7.14.1
- Nova Version: 3.6.0
- PHP Version: 7.3.11
- Database Driver & Version: MySQL 5.7.22
- Operating System and Version: Amazon Linux release 2
- Browser type and version: Chrome 81.0.4044.138
My scenario is as follows:
- Create databases (It set UTF8mb4 Unicode collation)
Create Model & Migration file (Table called "Area".)
php artisan make:model Area --migration
Modify the "area" migration file. Create 4 columns (id, name, created_at, updated_at)
Defining resource in the Nova admin panel.
php artisan nova:resource Area
Modify Nova's Resource file. adding this script to file.
public function fields(Request $request){ return [ ID::make()->sortable(), Text::make('Name') ->sortable() ->rules('required', 'max:24') ]; }
Insert Japanese data from Nova admin panel. I typed the Japanese word "北海道".
After clicking the update button, the data stored in the database will be garbled. I also want to say that the charset of garbled characters was "iso-8859-1".
That's my issue. I want to operate and manage Japanese data in Nova's admin panel!
Ofcourse, I was able to find some helpful questions from Stack overflow. For example, Laravel 5 Model $cats to array utf-8 JSON_UNESCAPED_UNICODE . It was told how to override the "toJson" function in the model, but It couldn't get involved with Laravel Nova.
When faced with such a multilingual problem, many of the Japanese references pointed out "To disable Unicode escaping in Laravel's json response.". But it didn't work too.
So problem is "Stop escaping Unicode in json response in Laravel Nova". But I'm not sure which file or which function to modify....
If anyone knows a solution, I would be grateful if you could give me a hint or solution.
Thank you.