3 namespace BookStack\Http\Controllers;
5 use BookStack\Actions\ActivityType;
6 use BookStack\Auth\User;
7 use BookStack\Settings\AppSettingsStore;
8 use BookStack\Uploads\ImageRepo;
9 use Illuminate\Http\Request;
11 class SettingController extends Controller
13 protected array $settingCategories = ['features', 'customization', 'registration'];
16 * Handle requests to the settings index path.
18 public function index()
20 return redirect('/settings/features');
24 * Display the settings for the given category.
26 public function category(string $category)
28 $this->ensureCategoryExists($category);
29 $this->checkPermission('settings-manage');
30 $this->setPageTitle(trans('settings.settings'));
32 // Get application version
33 $version = trim(file_get_contents(base_path('version')));
35 return view('settings.' . $category, [
36 'category' => $category,
37 'version' => $version,
38 'guestUser' => User::getDefault(),
43 * Update the specified settings in storage.
45 public function update(Request $request, AppSettingsStore $store, string $category)
47 $this->ensureCategoryExists($category);
48 $this->preventAccessInDemoMode();
49 $this->checkPermission('settings-manage');
50 $this->validate($request, [
51 'app_logo' => ['nullable', ...$this->getImageValidationRules()],
52 'app_icon' => ['nullable', ...$this->getImageValidationRules()],
55 $store->storeFromUpdateRequest($request, $category);
57 $this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
58 $this->showSuccessNotification(trans('settings.settings_save_success'));
60 return redirect("/settings/{$category}");
63 protected function ensureCategoryExists(string $category): void
65 if (!in_array($category, $this->settingCategories)) {