Commit 21b7a70d by mushishixian

fix

parent 6d285e2d
......@@ -14,26 +14,31 @@ class SupplierAccountValidator
public function checkSave($request)
{
//整理下请求数据
$receipt = $request->all();
$account = $request->all();
$rules = [
"supplier_code" => "required",
"mobile" => "required|regex:/^1[0-9][0-9]{9}$/",
"password_raw" => "required",
];
$messages = $this->messages();
$validator = Validator::make($receipt, $rules, $messages);
$validator = Validator::make($account, $rules, $messages);
//判断联系方式的表单验证
if ($validator->fails()) {
return $validator->errors()->first();
}
if (empty($receipt['id'])) {
if (empty($account['id'])) {
$model = new SupplierAccountModel();
$count = $model->where('supplier_code',$receipt['supplier_code'])
->orWhere('mobile',$receipt['mobile'])->count();
if ($count > 0) {
return '该供应商以及对应的账号已经存在,请更换手机号';
$supplierCount = $model->where('supplier_code', $account['supplier_code'])
->count();
if ($supplierCount > 0) {
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