I want to update/insert my parent directly with my child instead of separated them. After my validation rule has passed.
my code:
$validatedData = $request->validate([
'id' => 'bail|integer',
'code' => 'bail|integer',
'name' => 'bail|required|string|max:255',
'child' => 'bail|array',
'child.something' => 'bail|integer',
]);
$parent = Parent::updateOrCreate(['id' => $request->id, 'code' => $request->code], $validatedData);
CodePudding user response:
You can't. You need to update the child after the parent is successfully updated.