Support the ongoing development of →
Database Eloquent
Last updated 1 year ago.
Last updated 1 year ago.

For many-to-many, calling detach with no arguments will detach all:


You can also use sync to override the entire collection of models and replace it with an empty list:


Both are covered in the docs on many-to-many, but it's very easy to miss a lot of the variants (I don't think that many people even know about sync, for example).

Last updated 8 years ago.

Sign in to participate in this thread!


Your banner here too?

ErikEklund erikeklund Joined 14 Jun 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.