Laravel Faker小写

时间:2016-05-13 15:02:19

标签: laravel faker

这听起来很微不足道,但我似乎无法弄明白......

我通常有像我这样的db列;

Table Name: City
**id** - 1
**name** - Cityx
**value** - cityx

您可以看到名称完全相同,但是小写。 现在我正在尝试将$faker用于php,并想知道我将如何做到这一点

$factory->define(App\City::class, function ($faker) {
    return [
        'city' => $faker->city,
        'value' => , // make this lower case of $faker->city
    ];
});

1 个答案:

答案 0 :(得分:2)

$factory->define(App\City::class, function ($faker) {

    $city = $faker->city;

    return [
        'city' => $city,
        'value' => strtolower($city)
    ];
});