diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 795ad553..50c4fc5e 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -221,6 +221,20 @@ class UserController extends Controller return redirect()->route('admin.users.notifications')->with('success', 'Notification sent!'); } + /** + * @param User $user + * @return RedirectResponse + */ + public function toggleSuspended(User $user){ + try { + !$user->isSuspended() ? $user->suspend() : $user->unSuspend(); + } catch (Exception $exception) { + return redirect()->back()->with('error', $exception->getMessage()); + } + + return redirect()->back()->with('success', 'User has been updated!'); + } + /** * * @throws Exception @@ -252,10 +266,17 @@ class UserController extends Controller return $user->last_seen ? $user->last_seen->diffForHumans() : ''; }) ->addColumn('actions', function (User $user) { + $suspendColor = $user->isSuspended() ? "btn-success" : "btn-warning"; + $suspendIcon = $user->isSuspended() ? "fa-play-circle" : "fa-pause-circle"; + $suspendText = $user->isSuspended() ? "Unsuspend" : "Suspend"; return ' +