【发布时间】:2019-07-07 15:16:44
【问题描述】:
我为我的问题模型创建了一个问题工厂。我在问题模型中没有任何 id 字段,但我不明白工厂在哪里创建一个。
工厂
/* @var $factory \Illuminate\Database\Eloquent\Factory */
use App\Question;use Faker\Generator as Faker;
$factory->define(Question::class, function (Faker $faker) {
return [
'qid' => $faker->name,
'question' => $faker->sentence
];
});
廷克工厂的产出。
Psy Shell v0.9.9 (PHP 7.2.19 — cli) by Justin Hileman
>>> factory('App\Question')->create();
=> App\Question {#3001
qid: "Bell Schamberger",
question: "Consequatur debitis est nemo.",
updated_at: "2019-07-07 15:08:27",
created_at: "2019-07-07 15:08:27",
id: 0,
}
【问题讨论】:
-
迁移也没有什么?