Skip to content

Commit

Permalink
refactor(用户): 允许重置用户所有非必须字段
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Dec 25, 2018
1 parent 9e3078b commit 6980e96
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Http/Controllers/APIs/V2/CurrentUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ public function update(Request $request, ResponseFactoryContract $response)
if ($target) {
return $response->json(['name' => ['用户名已被使用']], 422);
}

foreach ($request->only(['name', 'bio', 'sex', 'location', 'avatar', 'bg']) as $key => $value) {
if (! is_null($value)) {
$user->$key = $value;
$fields = ['name', 'bio', 'sex', 'location', 'avatar', 'bg'];
foreach ($fields as $field) {
if ($request->request->has($field)) {
$user->{$field} = $request->input($field);
}
}

Expand Down

0 comments on commit 6980e96

Please sign in to comment.