So I am new to Laravel but not to LAMP development, I have been doing this since 1999 and I feel that by using a framework there should be a way to accomplish what I am after.
I have defined the relationships in my various models as need be, some are one to many, some are many to many, etc. When I query data, this works flawlessly. However my concern is with updating or inserting data.
I am sure there is a way to insert or update a record and have the necessary entries in the defined relationships also insert or update, I'm not not sure how to go about it. Where and how can I learn more about this?
From the official documentation:
$comment = new App\Comment(['message' => 'A new comment.']);
$post = App\Post::find(1);
$post->comments()->save($comment);
OR
$post = App\Post::find(1);
$comment = $post->comments()->create([
'message' => 'A new comment.',
]);
For other cases and exaples please refer to the link I gave you.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community