mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: user edit
This commit is contained in:
parent
232cb18a25
commit
0313c35dbe
@ -81,8 +81,12 @@ class UserController extends Controller
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
$user = User::find($request->input('id'));
|
||||
if ($user->invite_user_id) {
|
||||
$user['invite_user'] = User::find($user->invite_user_id);
|
||||
}
|
||||
return response([
|
||||
'data' => User::find($request->input('id'))
|
||||
'data' => $user
|
||||
]);
|
||||
}
|
||||
|
||||
@ -109,6 +113,14 @@ class UserController extends Controller
|
||||
}
|
||||
$params['group_id'] = $plan->group_id;
|
||||
}
|
||||
if ($request->input('invite_user_email')) {
|
||||
$inviteUser = User::where('email', $request->input('invite_user_email'))->first();
|
||||
if ($inviteUser) {
|
||||
$params['invite_user_id'] = $inviteUser->id;
|
||||
}
|
||||
} else {
|
||||
$params['invite_user_id'] = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$user->update($params);
|
||||
@ -265,30 +277,4 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function setInviteUser(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'user_id' => 'required|integer',
|
||||
'invite_user' => 'required',
|
||||
], [
|
||||
'user_id.required' => '用户ID不能为空',
|
||||
'user_id.integer' => '用户ID参数有误',
|
||||
'invite_user.required' => '邀请人不能为空'
|
||||
]);
|
||||
|
||||
$user = User::find($request->input('user_id'));
|
||||
if (!$user) abort(500, '用户不存在');
|
||||
if (strpos($request->input('invite_user'), '@') !== -1) {
|
||||
$inviteUser = User::where('email', $request->input('invite_user'))->first();
|
||||
} else {
|
||||
$inviteUser = User::find($request->input('invite_user'));
|
||||
}
|
||||
if (!$inviteUser) abort(500, '邀请人不存在');
|
||||
$user->invite_user_id = $inviteUser->id;
|
||||
|
||||
return response([
|
||||
'data' => $user->save()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user