In this episode, we shift gears from attaching relationships to learning how to detach them. After a quick recap, we set up a new route that will let us detach topics from a course (and you probably already have a guess how it's done if you saw the previous episode!).
First, we make sure our course actually has topics attached—like Laravel, Eloquent, and Inertia—just so we have something to work with. Then, we show how to use the detach
method to remove a topic (like Laravel) from the course. It's as simple as specifying the topic you want to get rid of and calling detach
on the relationship.
We walk through refreshing the page and seeing the topic disappear, confirming it's really gone. This episode is a straightforward demo showing that detaching relationships is just as easy as attaching them—just the opposite!
By the end, you'll see how you could let users remove topics from a course in your own apps using a similar approach.