+ /**
+ * Show the notification preferences for the current user.
+ */
+ public function showNotifications(PermissionApplicator $permissions)
+ {
+ $this->checkPermission('receive-notifications');
+ $this->preventGuestAccess();
+
+ $preferences = (new UserNotificationPreferences(user()));
+
+ $query = user()->watches()->getQuery();
+ $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
+ $query = $permissions->filterDeletedFromEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
+ $watches = $query->with('watchable')->paginate(20);
+
+ $this->setPageTitle(trans('preferences.notifications'));
+ return view('users.preferences.notifications', [
+ 'preferences' => $preferences,
+ 'watches' => $watches,
+ ]);
+ }
+
+ /**
+ * Update the notification preferences for the current user.
+ */
+ public function updateNotifications(Request $request)
+ {
+ $this->checkPermission('receive-notifications');
+ $this->preventGuestAccess();
+ $data = $this->validate($request, [
+ 'preferences' => ['required', 'array'],
+ 'preferences.*' => ['required', 'string'],
+ ]);
+
+ $preferences = (new UserNotificationPreferences(user()));
+ $preferences->updateFromSettingsArray($data['preferences']);
+ $this->showSuccessNotification(trans('preferences.notifications_update_success'));
+
+ return redirect('/preferences/notifications');
+ }
+