mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update user manage
This commit is contained in:
parent
f03c53815c
commit
53710f2e01
@ -59,21 +59,7 @@ class UserController extends Controller
|
|||||||
|
|
||||||
public function update(UserUpdate $request)
|
public function update(UserUpdate $request)
|
||||||
{
|
{
|
||||||
$updateData = $request->only([
|
$updateData = $request->only(array_keys(UserUpdate::RULES));
|
||||||
'email',
|
|
||||||
'password',
|
|
||||||
'transfer_enable',
|
|
||||||
'expired_at',
|
|
||||||
'banned',
|
|
||||||
'plan_id',
|
|
||||||
'commission_rate',
|
|
||||||
'discount',
|
|
||||||
'is_admin',
|
|
||||||
'u',
|
|
||||||
'd',
|
|
||||||
'balance',
|
|
||||||
'commission_balance'
|
|
||||||
]);
|
|
||||||
$user = User::find($request->input('id'));
|
$user = User::find($request->input('id'));
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
abort(500, '用户不存在');
|
abort(500, '用户不存在');
|
||||||
@ -92,6 +78,10 @@ class UserController extends Controller
|
|||||||
abort(500, '订阅计划不存在');
|
abort(500, '订阅计划不存在');
|
||||||
}
|
}
|
||||||
$updateData['group_id'] = $plan->group_id;
|
$updateData['group_id'] = $plan->group_id;
|
||||||
|
// plan type is onetime, set expired time 0
|
||||||
|
if ($plan->type === 1) {
|
||||||
|
$user->expired_at = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$user->update($updateData)) {
|
if (!$user->update($updateData)) {
|
||||||
abort(500, '保存失败');
|
abort(500, '保存失败');
|
||||||
|
@ -6,6 +6,21 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
|
|
||||||
class UserUpdate extends FormRequest
|
class UserUpdate extends FormRequest
|
||||||
{
|
{
|
||||||
|
CONST RULES = [
|
||||||
|
'email' => 'required|email',
|
||||||
|
'password' => 'nullable',
|
||||||
|
'transfer_enable' => 'numeric',
|
||||||
|
'expired_at' => 'integer',
|
||||||
|
'enable' => 'required|in:0,1',
|
||||||
|
'plan_id' => 'integer',
|
||||||
|
'commission_rate' => 'nullable|integer|min:0|max:100',
|
||||||
|
'discount' => 'nullable|integer|min:0|max:100',
|
||||||
|
'is_admin' => 'required|in:0,1',
|
||||||
|
'u' => 'integer',
|
||||||
|
'd' => 'integer',
|
||||||
|
'balance' => 'integer',
|
||||||
|
'commission_balance' => 'integer'
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
@ -13,15 +28,7 @@ class UserUpdate extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return self::RULES;
|
||||||
'email' => 'required|email',
|
|
||||||
'transfer_enable' => 'numeric',
|
|
||||||
'expired_at' => 'integer',
|
|
||||||
'is_admin' => 'required|in:0,1',
|
|
||||||
'plan_id' => 'integer',
|
|
||||||
'commission_rate' => 'nullable|integer|min:0|max:100',
|
|
||||||
'discount' => 'nullable|integer|min:0|max:100'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages()
|
||||||
@ -31,6 +38,8 @@ class UserUpdate extends FormRequest
|
|||||||
'email.email' => '邮箱格式不正确',
|
'email.email' => '邮箱格式不正确',
|
||||||
'transfer_enable.numeric' => '流量格式不正确',
|
'transfer_enable.numeric' => '流量格式不正确',
|
||||||
'expired_at.integer' => '到期时间格式不正确',
|
'expired_at.integer' => '到期时间格式不正确',
|
||||||
|
'enable.required' => '账户状态不能为空',
|
||||||
|
'enable.in' => '账户状态格式不正确',
|
||||||
'is_admin.required' => '是否管理员不能为空',
|
'is_admin.required' => '是否管理员不能为空',
|
||||||
'is_admin.in' => '是否管理员格式不正确',
|
'is_admin.in' => '是否管理员格式不正确',
|
||||||
'plan_id.integer' => '订阅计划格式不正确',
|
'plan_id.integer' => '订阅计划格式不正确',
|
||||||
@ -41,7 +50,11 @@ class UserUpdate extends FormRequest
|
|||||||
'discount.integer' => '专属折扣比例格式不正确',
|
'discount.integer' => '专属折扣比例格式不正确',
|
||||||
'discount.nullable' => '专属折扣比例格式不正确',
|
'discount.nullable' => '专属折扣比例格式不正确',
|
||||||
'discount.min' => '专属折扣比例最小为0',
|
'discount.min' => '专属折扣比例最小为0',
|
||||||
'discount.max' => '专属折扣比例最大为100'
|
'discount.max' => '专属折扣比例最大为100',
|
||||||
|
'u.integer' => '上行流量格式不正确',
|
||||||
|
'd.integer' => '下行流量格式不正确',
|
||||||
|
'balance' => '余额格式不正确',
|
||||||
|
'commission_balance' => '佣金格式不正确'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user