2023-07-31 23:08:29 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Activity\Controllers;
|
|
|
|
|
2023-08-09 21:53:31 +08:00
|
|
|
use BookStack\Activity\Tools\UserEntityWatchOptions;
|
2023-09-10 22:18:31 +08:00
|
|
|
use BookStack\Entities\Tools\MixedEntityRequestHelper;
|
2023-07-31 23:08:29 +08:00
|
|
|
use BookStack\Http\Controller;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class WatchController extends Controller
|
|
|
|
{
|
2023-09-10 22:18:31 +08:00
|
|
|
public function update(Request $request, MixedEntityRequestHelper $entityHelper)
|
2023-07-31 23:08:29 +08:00
|
|
|
{
|
2023-08-16 23:02:00 +08:00
|
|
|
$this->checkPermission('receive-notifications');
|
|
|
|
$this->preventGuestAccess();
|
|
|
|
|
2023-09-11 18:37:07 +08:00
|
|
|
$requestData = $this->validate($request, array_merge([
|
2023-07-31 23:08:29 +08:00
|
|
|
'level' => ['required', 'string'],
|
2023-09-11 18:37:07 +08:00
|
|
|
], $entityHelper->validationRules()));
|
2023-07-31 23:08:29 +08:00
|
|
|
|
2023-09-10 22:18:31 +08:00
|
|
|
$watchable = $entityHelper->getVisibleEntityFromRequestData($requestData);
|
2023-08-09 21:53:31 +08:00
|
|
|
$watchOptions = new UserEntityWatchOptions(user(), $watchable);
|
2023-08-18 01:10:34 +08:00
|
|
|
$watchOptions->updateLevelByName($requestData['level']);
|
2023-07-31 23:08:29 +08:00
|
|
|
|
2023-08-02 20:14:00 +08:00
|
|
|
$this->showSuccessNotification(trans('activities.watch_update_level_notification'));
|
|
|
|
|
2023-12-10 20:37:21 +08:00
|
|
|
return redirect($watchable->getUrl());
|
2023-07-31 23:08:29 +08:00
|
|
|
}
|
|
|
|
}
|