O'Reilly logo
  • GIL EG thinks this is interesting:

 $author = Author::where('first_name', '=', 'Jules')->where('last_name', '=', 'Verne')->first();

  $author->books->saveMany([
    new Book(['title' => 'Michael Strogoff']),
    new Book(['title' => 'The Mysterious Island']),
    new Book(['title' => 'Off on a Comet'])
  ])

From

Cover of Learning Laravel's Eloquent

Note

saveMany() to create multiple related model records on the fly