+ * @throws \Exception
+ */
+ public function destroy(int $id)
+ {
+ $this->preventAccessInDemoMode();
+ $this->checkPermissionOrCurrentUser('users-manage', $id);
+
+ $user = $this->userRepo->getById($id);
+
+ if ($this->userRepo->isOnlyAdmin($user)) {
+ $this->showErrorNotification(trans('errors.users_cannot_delete_only_admin'));
+ return redirect($user->getEditUrl());
+ }
+
+ if ($user->system_name === 'public') {
+ $this->showErrorNotification(trans('errors.users_cannot_delete_guest'));
+ return redirect($user->getEditUrl());
+ }
+
+ $this->userRepo->destroy($user);
+ $this->showSuccessNotification(trans('settings.users_delete_success'));
+
+ return redirect('/settings/users');
+ }
+
+ /**
+ * Show the user profile page
+ */
+ public function showProfilePage($id)
+ {
+ $user = $this->userRepo->getById($id);
+
+ $userActivity = $this->userRepo->getActivity($user);
+ $recentlyCreated = $this->userRepo->getRecentlyCreated($user, 5);
+ $assetCounts = $this->userRepo->getAssetCounts($user);
+
+ return view('users.profile', [
+ 'user' => $user,
+ 'activity' => $userActivity,
+ 'recentlyCreated' => $recentlyCreated,
+ 'assetCounts' => $assetCounts
+ ]);
+ }
+
+ /**
+ * Update the user's preferred book-list display setting.
+ */
+ public function switchBooksView(Request $request, int $id)
+ {
+ return $this->switchViewType($id, $request, 'books');
+ }
+
+ /**
+ * Update the user's preferred shelf-list display setting.
+ */
+ public function switchShelvesView(Request $request, int $id)
+ {
+ return $this->switchViewType($id, $request, 'bookshelves');
+ }
+
+ /**
+ * Update the user's preferred shelf-view book list display setting.
+ */
+ public function switchShelfView(Request $request, int $id)
+ {
+ return $this->switchViewType($id, $request, 'bookshelf');
+ }
+
+ /**
+ * For a type of list, switch with stored view type for a user.