📜  一次保存多个模型 - 无论代码示例

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

代码示例1
You can save multiple models at once using the saveMany function:

$post = Post::find(1);
$post->comments()->saveMany([
    new Comment(['message' => 'This a new comment']),
    new Comment(['message' => 'Me too!']),
    new Comment(['message' => 'Eloquent is awesome!'])
]);