laravel-learn-bbs/database/factories/TopicFactory.php
2018-01-01 12:38:52 +08:00

22 lines
610 B
PHP

<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Topic::class, function (Faker $faker) {
//随机生成『小段落』文本
$sentence = $faker->sentence();
// 随机取一个月以内的时间
$updated_at = $faker->dateTimeThisMonth();
// 传参为生成最大时间不超过,创建时间永远比更改时间要早
$created_at = $faker->dateTimeThisMonth($updated_at);
return [
'title' => $sentence,
'body' => $faker->text(),
'excerpt' => $sentence,
'created_at' => $created_at,
'updated_at' => $updated_at,
];
});