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