这听起来很微不足道,但我似乎无法弄明白......
我通常有像我这样的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
];
});
答案 0 :(得分:2)
$factory->define(App\City::class, function ($faker) {
$city = $faker->city;
return [
'city' => $city,
'value' => strtolower($city)
];
});