|
|
@ -198,19 +198,12 @@ class AgentProductController extends AdminController |
|
|
$where = [ |
|
|
$where = [ |
|
|
['agent_id', '=', $agent_id], |
|
|
['agent_id', '=', $agent_id], |
|
|
['product_id', '=', $form->product_id], |
|
|
['product_id', '=', $form->product_id], |
|
|
|
|
|
['product_ids', '=', $form->product_ids], |
|
|
]; |
|
|
]; |
|
|
if ($form->isEditing()) { |
|
|
if ($form->isEditing()) { |
|
|
$where[] = ['id', '<>', $form->getKey()]; |
|
|
$where[] = ['id', '<>', $form->getKey()]; |
|
|
} |
|
|
} |
|
|
$agent_product = $form->repository()->model()->withTrashed()->where($where)->first(); |
|
|
|
|
|
if ($agent_product) { |
|
|
|
|
|
//如果已经软删除了,解除软删除后再更新
|
|
|
|
|
|
if ($agent_product->deleted_at) { |
|
|
|
|
|
$agent_product->deleted_at = null; |
|
|
|
|
|
$form->deleteInput('sale'); //保留原来的销量
|
|
|
|
|
|
$agent_product->update($form->input()); |
|
|
|
|
|
return $form->response()->success('保存成功')->script('history.back();'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ($form->repository()->model()->where($where)->exists()) { |
|
|
return $form->response()->error('该产品已经存在,请勿重复发布'); |
|
|
return $form->response()->error('该产品已经存在,请勿重复发布'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|