]> BookStack Code Mirror - bookstack/blob - app/Activity/Controllers/WatchController.php
d63918fb35044d01c807d5641126d0e465434d37
[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, [
18             'level' => ['required', 'string'],
19             ...$entityHelper->validationRules()
20         ]);
21
22         $watchable = $entityHelper->getVisibleEntityFromRequestData($requestData);
23         $watchOptions = new UserEntityWatchOptions(user(), $watchable);
24         $watchOptions->updateLevelByName($requestData['level']);
25
26         $this->showSuccessNotification(trans('activities.watch_update_level_notification'));
27
28         return redirect()->back();
29     }
30 }