Updating multiple many to many relationships

Posted 5 months ago by bcharron

I am wondering if there is a best practice when it comes to updating the pivot table for a many to many relationship. I currently have the following code which updates each pivot table record individually, but wonder if there is a better way to do this?

foreach( $job->codes as $code ) {
            'approved' => 1

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.