Skip to content
Advertisement

Change Faker Locale in Laravel 5.2

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(AppFlyer::class, function (FakerGenerator $faker) {

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

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

Thanks for reading!

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement