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-07-31 23:08:29 +08:00
|
|
|
$requestData = $this->validate($request, [
|
|
|
|
'level' => ['required', 'string'],
|
2023-09-10 22:18:31 +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'));
|
|
|
|
|
|
|
|
return redirect()->back();
|
2023-07-31 23:08:29 +08:00
|
|
|
}
|
|
|
|
}
|