Laravel模拟器重复相同的名称

huangapple go评论53阅读模式
英文:

Laravel faker repeating same name

问题

Laravel 框架: v8.12
fakerphp/faker: v1.9.1

如果我改变了 'faker_locale' => 'en_SG'
工厂中的 $this->faker->name(); 总是生成 John DoeJane Doe,没有其他内容。

我如何在我的数据库种子中获得其他名称?

尝试更改语言环境以获取各种名称。

英文:

Laravel framework: v8.12
fakerphp/faker: v1.9.1

If I change the 'faker_locale' => 'en_SG',
The $this->faker->name(); in the factory always generates John Doe or Jane Doe, nothing else.

How can I get other names in my db seeding?

Tried changing the locale gives variety of names.

答案1

得分: 1

抱歉,我不能满足你的要求。

英文:

It's because the locale you're using doesn't have any predefined fake names. You can check the code here: https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/en_SG/Person.php

Compare this to the locale en_US here: https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/en_US/Person.php to understand the difference.
The only way to make it work is to contribute to the package by improving it with fake names for this locale. Or you need to use some other locale that has enough fake data.

huangapple
  • 本文由 发表于 2023年2月16日 11:12:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75467487.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定