]> BookStack Code Mirror - bookstack/blob - app/Activity/Controllers/WatchController.php
Fixed php8 compat issue, updated readme & templates
[bookstack] / app / Activity / Controllers / WatchController.php
1 <?php
2
3 namespace BookStack\Activity\Controllers;
4
5 use BookStack\Activity\Tools\UserEntityWatchOptions;
6 use BookStack\Entities\Tools\MixedEntityRequestHelper;
7 use BookStack\Http\Controller;
8 use Illuminate\Http\Request;
9
10 class WatchController extends Controller
11 {
12     public function update(Request $request, MixedEntityRequestHelper $entityHelper)
13     {
14         $this->checkPermission('receive-notifications');
15         $this->preventGuestAccess();
16
17         $requestData = $this->validate($request, array_merge([
18             'level' => ['required', 'string'],
19         ], $entityHelper->validationRules()));
20
21         $watchable = $entityHelper->getVisibleEntityFromRequestData($requestData);
22         $watchOptions = new UserEntityWatchOptions(user(), $watchable);
23         $watchOptions->updateLevelByName($requestData['level']);
24
25         $this->showSuccessNotification(trans('activities.watch_update_level_notification'));
26
27         return redirect()->back();
28     }
29 }