id_branch is PK, id_item is PK&FK
$id = B;
$id_selected = A;
$from_category= Category::where('id_branch', $id_selected)->get();
foreach ($from_items as $from_item) {
$test = Category::updateOrCreate(['id_branch' => $id,'id_item'=>$from_item->id_item], ['remarks' => $from_item->remarks]);
}
For example, user will select which branch category record need to be copied to the current branch category. After that will update or insert the record from the branch category selected to current one. Copy branch category A record to branch category B. If exist then update else insert. I able to insert the record but when update the value will be null. Anything wrong with my code?