how to insert data in relationship table laravel 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.',
],
]);