3 namespace BookStack\Settings;
5 use BookStack\Activity\ActivityType;
6 use BookStack\Http\Controller;
7 use BookStack\Users\Models\User;
8 use Illuminate\Http\Request;
10 class SettingController extends Controller
12 protected array $settingCategories = ['features', 'customization', 'registration'];
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('settings-manage');
29 $this->setPageTitle(trans('settings.settings'));
31 // Get application version
32 $version = trim(file_get_contents(base_path('version')));
34 return view('settings.' . $category, [
35 'category' => $category,
36 'version' => $version,
37 'guestUser' => User::getDefault(),
42 * Update the specified settings in storage.
44 public function update(Request $request, AppSettingsStore $store, string $category)
46 $this->ensureCategoryExists($category);
47 $this->preventAccessInDemoMode();
48 $this->checkPermission('settings-manage');
49 $this->validate($request, [
50 'app_logo' => ['nullable', ...$this->getImageValidationRules()],
51 'app_icon' => ['nullable', ...$this->getImageValidationRules()],
54 $store->storeFromUpdateRequest($request, $category);
55 $this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
57 return redirect("/settings/{$category}");
60 protected function ensureCategoryExists(string $category): void
62 if (!in_array($category, $this->settingCategories)) {