abortUnlessCanManage($request, $project); return Inertia::render( 'projects/settings/Notifications', $this->buildProjectNotificationSettingsPayload->handle($project, session('status')), ); } public function store( StoreProjectNotificationActionRequest $request, Project $project, ): RedirectResponse { $this->abortUnlessCanManage($request, $project); $notificationAction = $this->storeProjectNotificationAction->handle($project, $request->validated()); return to_route('projects.settings.notifications', $project) ->with('status', "{$notificationAction->name} notification was added."); } public function update( UpdateProjectNotificationActionRequest $request, Project $project, NotificationAction $notificationAction, ): RedirectResponse { $this->abortUnlessCanManage($request, $project); $notificationAction = $this->updateProjectNotificationAction->handle( $project, $notificationAction, $request->validated(), ); return to_route('projects.settings.notifications', $project) ->with('status', "{$notificationAction->name} notification was updated."); } public function destroy( Request $request, Project $project, NotificationAction $notificationAction, ): RedirectResponse { $this->abortUnlessCanManage($request, $project); $notificationAction = $project->notificationActions() ->whereKey($notificationAction->id) ->firstOrFail(); $deletedName = $notificationAction->name; $this->deleteProjectNotificationAction->handle($project, $notificationAction); return to_route('projects.settings.notifications', $project) ->with('status', "{$deletedName} notification was deleted."); } private function abortUnlessCanManage(Request $request, Project $project): void { abort_unless( $this->permissionService->allows($request->user(), Permission::ProjectAdmin, $project), 403, ); } }