I want to update my related table on laravel 5.4
my code
$id=$request->id;
$find=Presal::find($id);
$find->user_id=$request->customer_id;
$find->proposalid=$request->proposalid;
$psal=$find->save();
if($psal)
{
foreach( $request->service_item_id as $key => $n ) {
$find->proposalService()->updateOrCreate([
'service_item_id' => $request->service_item_id[$key],
'start_date' => $request->start_date[$key],
'end_date' => $request->end_date[$key],
'service_type_id' => $request->service_type_id[$key],
'vendor_submit' => $request->vendor_submit[$key]
]);
}
}
Here always my code create a new row in proposalService but not update. How can I make create if new and Update if exist.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire