Is there a way to specify the Faker locale in the database/factories/ModelFactory.php file ? Here is my non functioning attempt at doing so >,<

$factory->define(App\Flyer::class, function (Faker\Generator $faker) {

    // What is the correct way of doing this?
    $faker->locale('en_GB'); 

    return [
        'zip' => $faker->postcode,
        'state' => $faker->state,  
    ];
});

Thanks for reading!

推荐答案

Faker locale can be configured in the config/app.php configuration file. Just add the key faker_locale.

e.g.: 'faker_locale' => 'fr_FR',

See also my PR to document that previously undocumented feature: https://github.com/laravel/laravel/pull/4161

Laravel相关问答推荐

在没有lang/*.json文件的情况下在Laravel项目中实现多语言支持

使用MAATWebSite/EXCEL导入Exel时,不会创建Laravel模型

Laravel 获取具有多对多关系的中间表数据

自定义 Laravel 关系?

Laravel 合集日期比较

Laravel Request::input 调用未定义的方法

Laravel:如何在没有数据库的情况下对用户进行身份验证

致命错误:找不到类App\Http\Controllers\Redirect

合并和排序两个 Eloquent 集合?

在 laravel 5.2 中禁用特定路由的 Web 中间件

laravel 预期响应代码 250 但得到代码530

Homestead:文件夹映射到错误的文档根目录

升级到 Laravel 5.2 会使所有会话失效

Laravel 分页方法不适用于 map 集合?

Laravel Eloquent 在子查询中有两个WHERE NOT IN

Laravel 搜索关系

Grammar::parameterize() 必须是数组类型

如何在 Laravel 中使用补丁请求?

Laravel 验证存在于不存在的地方

如何从 laravel 5.1 中数据库表的 created_at 属性中 Select 年份和月份?