📜  laravel 播种与关系 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:45.356000             🧑  作者: Mango

代码示例1
//create 10 users
factory(User::class, 10)->create()->each(function ($user) {
    //create 5 posts for each user
    factory(Post::class, 5)->create(['user_id'=>$user->id]);
});