File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -87,15 +87,15 @@ $post->load('featuredImage');
8787```
8888Prefer 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
You can’t perform that action at this time.
0 commit comments