admin管理员组文章数量:1405570
I have a Laravel seeder that is only inserting one record when I have a factory and the seeder should insert 2500 records.
Factory:
public function definition(): array
{
$timestamp = $this->getFakeTimestamp();
return [
'title' => $this->faker->sentence(),
'body' => $this->faker->paragraph(),
'more_inside' => $this->faker->paragraph(),
'subsite_id' => (new Subsite())->inRandomOrder()->first(),
'user_id' => (new User())->inRandomOrder()->first(),
'created_at' => $timestamp,
'published_at' => $timestamp,
'updated_at' => null,
'deleted_at' => null,
'is_published' => true,
'state' => PostStateEnum::Published->value,
];
}
Seeder:
final class FakePostSeeder extends Seeder
{
private const int NUMBER_OF_FAKE_POSTS = 2500;
public function run(): void
{
DB::connection()->disableQueryLog();
Post::factory(self::NUMBER_OF_FAKE_POSTS)->create();
}
}
One one row gets inserted, even if I replace the constant with an integer.
Passing the desired number with count doesn't work, either:
{
DB::connection()->disableQueryLog();
Post::factory()
->count(self::NUMBER_OF_FAKE_POSTS)
->create();
}
本文标签: Laravel seeder only inserting one record should insert 2500Stack Overflow
版权声明:本文标题:Laravel seeder only inserting one record; should insert 2500 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744907078a2631687.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论