diff --git a/app/Admin/Controllers/AgentController.php b/app/Admin/Controllers/AgentController.php index 5aaec3e..43ffb77 100644 --- a/app/Admin/Controllers/AgentController.php +++ b/app/Admin/Controllers/AgentController.php @@ -152,9 +152,16 @@ class AgentController extends AdminController $form->editor('agentInfo.reg_protocol', '注册协议'); $form->editor('agentInfo.buy_protocol', '购买协议'); })->saving(function (Form $form) { + //判断账号是否唯一 + if ($form->isCreating()) { + if ($form->repository()->model()->where('account', $form->account)->exists()) { + return $form->response()->error($form->account . ' 的账号已经存在'); + } + } + //不允许编辑的字段 if ($form->isEditing()) { - $form->ignore(['id', 'account', 'created_at', 'updated_at']); + $form->ignore(['id', 'account', 'created_at', 'updated_at', 'deleted_at']); } //过滤null字段 diff --git a/app/Admin/Controllers/SupplierController.php b/app/Admin/Controllers/SupplierController.php index a8f5d8c..94aa050 100644 --- a/app/Admin/Controllers/SupplierController.php +++ b/app/Admin/Controllers/SupplierController.php @@ -124,9 +124,16 @@ class SupplierController extends AdminController $form->text('director'); $form->mobile('contact_phone'); })->saving(function (Form $form) { + //判断账号是否唯一 + if ($form->isCreating()) { + if ($form->repository()->model()->where('account', $form->account)->exists()) { + return $form->response()->error($form->account . ' 的账号已经存在'); + } + } + //不允许编辑的字段 if ($form->isEditing()) { - $form->ignore(['id', 'account', 'created_at', 'created_at', 'deleted_at']); + $form->ignore(['id', 'account', 'created_at', 'created_at', 'deleted_at', 'deleted_at']); } //过滤null字段