Commit 820eb477 authored by Viral Solani's avatar Viral Solani

resolve error of update user API

parent 3090ca17
......@@ -86,9 +86,11 @@ class UsersController extends APIController
return $this->throwValidation($validation->messages()->first());
}
$updatedUser = $this->repository->update($user, $request);
$this->repository->update($user, $request);
return new UserResource($updatedUser);
$user = User::findOrfail($user->id);
return new UserResource($user);
}
/**
......
......@@ -20,8 +20,11 @@ class UserResource extends Resource
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->email,
'picture' => $this->getPicture(),
'confirmed' => $this->confirmed,
'role' => optional($this->roles()->first())->name,
'permissions' => $this->permissions()->get(),
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
];
......
......@@ -144,7 +144,7 @@ class UserRepository extends BaseRepository
if ($user->update($data)) {
$user->status = isset($data['status']) ? 1 : 0;
$user->confirmed = isset($data['confirmed']) ? 1 : 0;
$updatedUser = tap($user)->save();
$user->save();
$this->checkUserRolesCount($roles);
$this->flushRoles($roles, $user);
......@@ -152,7 +152,7 @@ class UserRepository extends BaseRepository
$this->flushPermissions($permissions, $user);
event(new UserUpdated($user));
return $updatedUser;
return true;
}
throw new GeneralException(trans('exceptions.backend.access.users.update_error'));
......
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 to comment