I did this for reference.
define(AppUser::class, function (FakerGenerator $faker) {
static $password;
$tw_faker = TwFacker::create('zh_TW');
return [
'name' => $tw_faker->name,
'address' => $tw_faker->address,
'city' => preg_replace('#(.{3})(.*)#um', '$1', $tw_faker->city),
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
});
Customize a TwFacker alias, we can use him.Here,
$tw_faker->name
is used to replace the original $faker->name provided by $faker->name
, so the Chinese name can be stored.We can also adjust relevant localized files in vendor/fzaninotto/faker/src/Faker/Provider/zh_TW in Laravel's special security directory.
For example, the text of Text.php can generate fake data Chinese that is more in line with our needs..
https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/zh_TW/Text.php
No Comment
Post your comment