Skip to content

Commit 8129fde

Browse files
authored
Update README.md
1 parent 2043e08 commit 8129fde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ $post->load('featuredImage');
8787
```
8888
Prefer using `sync` instead of `save` when updating your relation.
8989
```php
90-
$post->featuredImage()->sync([FeaturedImage::find(123)]);
91-
$post->featuredImage()->sync([FeaturedImage::find(456)]);
90+
$post->featuredImage()->sync([Image::find(123)]);
91+
$post->featuredImage()->sync([Image::find(456)]);
9292
$post->images->count(); // 1 row :)
9393
```
9494

9595
:x: DO NOT use `save` it will follow `morphToMany` behaviour and create a new row instead of updating an existing one.
9696
```php
97-
$post->featuredImage()->save(FeaturedImage::find(123));
98-
$post->featuredImage()->save(FeaturedImage::find(456));
97+
$post->featuredImage()->save(Image::find(123));
98+
$post->featuredImage()->save(Image::find(456));
9999
$post->images->count(); // 2 rows :(
100100
```
101101

0 commit comments

Comments
 (0)