Skip to content

Commit 3a30bf7

Browse files
committed
Adding information about new associate and dissociate methods for embedsMany relations
1 parent de18ed4 commit 3a30bf7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ You can remove an embedded document by using the `destroy()` method:
398398
// or
399399
$user->books()->destroy($book);
400400

401+
If you want to add or remove embedded documents, without persistence, you can use the `associate` and `dissociate` methods. To write the changes to the database, save the parent object:
402+
403+
$user->books()->associate($book);
404+
$user->save();
405+
401406
Again, you may override the conventional local key by passing a second argument to the embedsMany method:
402407

403408
return $this->embedsMany('Book', 'local_key');

0 commit comments

Comments
 (0)