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.
Published on Aug 8th, 2016.
Understand.io is used by hundreds of Laravel developers to find and fix errors.
Sign up for a free 14-day trial now.