Commit 21b7a70d by mushishixian

fix

parent 6d285e2d
...@@ -14,26 +14,31 @@ class SupplierAccountValidator ...@@ -14,26 +14,31 @@ class SupplierAccountValidator
public function checkSave($request) public function checkSave($request)
{ {
//整理下请求数据 //整理下请求数据
$receipt = $request->all(); $account = $request->all();
$rules = [ $rules = [
"supplier_code" => "required", "supplier_code" => "required",
"mobile" => "required|regex:/^1[0-9][0-9]{9}$/", "mobile" => "required|regex:/^1[0-9][0-9]{9}$/",
"password_raw" => "required", "password_raw" => "required",
]; ];
$messages = $this->messages(); $messages = $this->messages();
$validator = Validator::make($receipt, $rules, $messages); $validator = Validator::make($account, $rules, $messages);
//判断联系方式的表单验证 //判断联系方式的表单验证
if ($validator->fails()) { if ($validator->fails()) {
return $validator->errors()->first(); return $validator->errors()->first();
} }
if (empty($receipt['id'])) { if (empty($account['id'])) {
$model = new SupplierAccountModel(); $model = new SupplierAccountModel();
$count = $model->where('supplier_code',$receipt['supplier_code']) $supplierCount = $model->where('supplier_code', $account['supplier_code'])
->orWhere('mobile',$receipt['mobile'])->count(); ->count();
if ($count > 0) { if ($supplierCount > 0) {
return '该供应商以及对应的账号已经存在,请更换手机号'; return '该供应商已经存在账号';
}
$mobileCount = $model->where('mobile', $account['mobile'])
->count();
if ($mobileCount > 0) {
return '该手机号已经被注册';
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment