In Laravel 5.3, you'll find a new
toggle() method on all
belongsToMany relationships. This solves the issue of needing to delete a pivot table record if it exists, or adding it if it doesn't. As an example, consider needing to toggle a user's "like" status for a post.