delete record on update and insert if update record is new and update existing in laravel code example
Example: update or create laravel
$user = User::updateOrCreate(['name' => request()->name], [
'foo' => request()->foo
]);
$user = User::updateOrCreate(['name' => request()->name], [
'foo' => request()->foo
]);