-
How do I insert multiple items? |
Beta Was this translation helpful? Give feedback.
Answered by
JenuelDev
Aug 2, 2022
Replies: 1 comment
-
It seems I figured it out. It would be awesome if we could add this inside the documentation that way, when people is looking for it it will be easy. I was able to figure it out by using a function example: $post = Post::create([
'title' => $this->title,
'content' => $this->content
]);
$tags = array_map(function ($tag) {
return ['name' => $tag];
}, $this->tags);
$post->tags()->createMany($tags); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
JenuelDev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems I figured it out. It would be awesome if we could add this inside the documentation that way, when people is looking for it it will be easy.
I was able to figure it out by using a function
createMany
.example: