has many relationship laravel insert code example
Example: add the data inside has many relationship laravel
$post = App\Models\Post::find(1);
$comment = $post->comments()->create([
'message' => 'A new comment.',
]);
--------------- OR ------------------
$post->comments()->createMany([
[
'message' => 'A new comment.',
],
[
'message' => 'Another new comment.',
],
]);