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

$author = Author::where('first_name', '=', 'Jules')->where('last_name', '=', 'Verne')->first(); $author->books->save(new Book([ 'title' => 'Michael Strogoff', // other attributes... ]));

From

Cover of Learning Laravel's Eloquent

Note

create new related model record just on the fly