3 namespace BookStack\Settings;
5 use BookStack\Activity\ActivityType;
6 use BookStack\App\AppVersion;
7 use BookStack\Http\Controller;
8 use BookStack\Permissions\Permission;
9 use BookStack\Users\Models\User;
10 use Illuminate\Http\Request;
12 class SettingController extends Controller
15 * Handle requests to the settings index path.
17 public function index()
19 return redirect('/settings/features');
23 * Display the settings for the given category.
25 public function category(string $category)
27 $this->ensureCategoryExists($category);
28 $this->checkPermission(Permission::SettingsManage);
29 $this->setPageTitle(trans('settings.settings'));
31 return view('settings.categories.' . $category, [
32 'category' => $category,
33 'version' => AppVersion::get(),
34 'guestUser' => User::getGuest(),
39 * Update the specified settings in storage.
41 public function update(Request $request, AppSettingsStore $store, string $category)
43 $this->ensureCategoryExists($category);
44 $this->preventAccessInDemoMode();
45 $this->checkPermission(Permission::SettingsManage);
46 $this->validate($request, [
47 'app_logo' => ['nullable', ...$this->getImageValidationRules()],
48 'app_icon' => ['nullable', ...$this->getImageValidationRules()],
51 $store->storeFromUpdateRequest($request, $category);
52 $this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
54 return redirect("/settings/{$category}");
57 protected function ensureCategoryExists(string $category): void
59 if (!view()->exists('settings.categories.' . $category)) {