mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Fixed restore again.
For some reason, $user->restore() isn't working? WTF.
This commit is contained in:
parent
0a5e7214aa
commit
a0b080b91d
|
@ -495,25 +495,23 @@ class UsersController extends Controller
|
||||||
*/
|
*/
|
||||||
public function getRestore($id = null)
|
public function getRestore($id = null)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
// Get user information
|
// Get user information
|
||||||
if (!$user = User::withTrashed()->find($id)) {
|
if (!$user = User::onlyTrashed()->find($id)) {
|
||||||
return Redirect::route('users')->with('error', trans('admins/users/messages.user_not_found'));
|
return Redirect::route('users')->with('error', trans('admin/users/messages.user_not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Company::isCurrentUserHasAccess($user)) {
|
if (!Company::isCurrentUserHasAccess($user)) {
|
||||||
return Redirect::route('users')->with('error', trans('general.insufficient_permissions'));
|
return Redirect::route('users')->with('error', trans('general.insufficient_permissions'));
|
||||||
} else {
|
} else {
|
||||||
// Restore the user
|
|
||||||
$user->restore();
|
|
||||||
return Redirect::route('users')->with('success', trans('admin/users/message.success.restored'));
|
|
||||||
}
|
|
||||||
} catch (UserNotFoundException $e) {
|
|
||||||
// Prepare the error message
|
|
||||||
$error = trans('admin/users/message.user_not_found', compact('id'));
|
|
||||||
|
|
||||||
// Redirect to the user management page
|
// Restore the user
|
||||||
return Redirect::route('users')->with('error', $error);
|
if (User::withTrashed()->where('id',$id)->restore()) {
|
||||||
|
return Redirect::route('users')->with('success', trans('admin/users/message.success.restored'));
|
||||||
|
} else {
|
||||||
|
return Redirect::route('users')->with('error','User could not be restored.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +611,7 @@ class UsersController extends Controller
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the user information
|
// Get the user information
|
||||||
$user_to_clone = User::find($id);
|
$user_to_clone = User::withTrashed()->find($id);
|
||||||
$user = clone $user_to_clone;
|
$user = clone $user_to_clone;
|
||||||
$user->first_name = '';
|
$user->first_name = '';
|
||||||
$user->last_name = '';
|
$user->last_name = '';
|
||||||
|
|
Loading…
Reference in a new issue