Commit 25d1b1c3 by 宁成龙

当客户类型为公司时,公司名必填

parent aff1a7a5
...@@ -91,7 +91,7 @@ class UserController extends AdminController ...@@ -91,7 +91,7 @@ class UserController extends AdminController
]; ];
$validator = Validator::make($params, [ $validator = Validator::make($params, [
'company_name' => 'required', // 'company_name' => 'required',
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'phone' => 'required', 'phone' => 'required',
...@@ -112,6 +112,12 @@ class UserController extends AdminController ...@@ -112,6 +112,12 @@ class UserController extends AdminController
$error = $validator->errors()->first(); $error = $validator->errors()->first();
throw new \Exception($error); throw new \Exception($error);
} }
if ($params['account_properties'] == \App\Models\User::ACCOUNT_PROPERTIES_ENTERPRISE) {
if (empty($params['company_name'])) {
throw new \Exception(trans("user.error_msg.requiredByCompanyName"));
}
}
UserService::createUserAndAddress($params); UserService::createUserAndAddress($params);
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
// var_dump((string)$throwable); // var_dump((string)$throwable);
......
...@@ -33,6 +33,11 @@ class EditUserHandle extends Form implements LazyRenderable ...@@ -33,6 +33,11 @@ class EditUserHandle extends Form implements LazyRenderable
$input = array_filter($input, function ($value) { $input = array_filter($input, function ($value) {
return $value !== null; return $value !== null;
}); });
if ($input['account_properties'] == \App\Models\User::ACCOUNT_PROPERTIES_ENTERPRISE) {
if (empty($input['company_name'])) {
throw new \Exception(trans("user.error_msg.requiredByCompanyName"));
}
}
User::updateById($id, $input); User::updateById($id, $input);
return $this return $this
...@@ -53,7 +58,7 @@ class EditUserHandle extends Form implements LazyRenderable ...@@ -53,7 +58,7 @@ class EditUserHandle extends Form implements LazyRenderable
$this->disableResetButton(); $this->disableResetButton();
$this->hidden('id')->attribute('id', 'id')->width(4); $this->hidden('id')->attribute('id', 'id')->width(4);
$this->row(function (Row $form) { $this->row(function (Row $form) {
$form->width(5)->text('company_name')->required(); $form->width(5)->text('company_name');
$form->width(5)->text('user_sn')->disable(); $form->width(5)->text('user_sn')->disable();
}); });
$this->row(function (Row $form) { $this->row(function (Row $form) {
......
...@@ -26,7 +26,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable ...@@ -26,7 +26,7 @@ class CreateUser extends \Dcat\Admin\Support\LazyRenderable
$form->disableResetButton(); $form->disableResetButton();
$form->disableCreatingCheck(); $form->disableCreatingCheck();
$form->row(function (Form\Row $form) { $form->row(function (Form\Row $form) {
$form->width(4)->text('company_name')->required(); $form->width(4)->text('company_name');
$form->width(4)->text('user_sn')->disable(); $form->width(4)->text('user_sn')->disable();
}); });
$form->row(function (Form\Row $form) { $form->row(function (Form\Row $form) {
......
...@@ -48,4 +48,7 @@ return [ ...@@ -48,4 +48,7 @@ return [
"2" => "Enterprise" "2" => "Enterprise"
], ],
], ],
"error_msg"=>[
"requiredByCompanyName"=>"Company name is required when account properties is company",
]
]; ];
...@@ -48,4 +48,7 @@ return [ ...@@ -48,4 +48,7 @@ return [
"2" => "企业" "2" => "企业"
], ],
], ],
"error_msg"=>[
"requiredByCompanyName"=>"当帐户属性为公司时,需要公司名称必填",
]
]; ];
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