You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose we are submitting a form and changing the year of the second book to 1957.
// submit author object with 1-to-many books:$_POST = [
'id' => 1,
'name' => 'Jack Kerouac',
'books' => [
[
'id' => 1,
'title' => 'The Town and the City',
'year' => 1950
],
[
'id' => 2,
'title' => 'On the Road',
'year' => 1957 // this value is different than what is in the db
]
]
];
use \My\Model\author;
// this does not work as expected// (the value is not updated in the db, however inserting a new book does work)$author = author::get($_POST)->save();
// until this is fixed, there is a work-around// save the books first, then save the author$author = author::get($_POST);
foreach ($author->booksas$book) {
$book->save();
}
$author->save();
The text was updated successfully, but these errors were encountered:
Suppose we are submitting a form and changing the
year
of the second book to1957
.The text was updated successfully, but these errors were encountered: