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

 $category = Category::where('name', '=', 'Opera')->first();

  $book = Book::where('title', '=', 'Journey to the Center of the Earth')->first();

  $category->books->attach(
    $book->id, 
    ['notes' 

From

Cover of Learning Laravel's Eloquent

Note

detach() to delete a pivot table record