Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Smashing's avatar

Update on multiple rows

How can I do inside a resource an update on multiple rows in case i use a multiselect option and i wanna be able when the user updates his choices to be able to update more rows not just one?

0 likes
3 replies
Tray2's avatar

You need to loop through the array of selected values and store them one by one.

something like this

foreach ($request->authors as $author) {
            AuthorBook::create([
                'author_id' => $author,
                'book_id' => $book->id
            ]);
        }
Smashing's avatar

yes, but my problem is when i display on the update page what i show tot the user lets say a booleangroup the values shown will be updated only on one row not on multiple rows

Tell me if you understand what i m trying to say, please!

Sinnbeck's avatar

Please show some code. How does the input code look?

Please or to participate in this conversation.