Laravel Eloquent Relationships: Lesson 4 of 7

One to Many Tips

Up Next

One to Many in View

Autoplaying in 7 seconds!

Cancel

While we can save a model directly to the relationships of another using saveMany(), we can also just associate a model with another. This will fill the proper user_id field.

Table of Contents

    $post->author()->associate($user);

    Chris Sevilleja

    173 posts

    Co-founder of Scotch.io. Slapping the keyboard until something good happens.