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
13 * Handle requests to the settings index path.
15 public function index()
17 return redirect('/settings/features');
21 * Display the settings for the given category.
23 public function category(string $category)
25 $this->ensureCategoryExists($category);
26 $this->checkPermission('settings-manage');
27 $this->setPageTitle(trans('settings.settings'));
29 // Get application version
30 $version = trim(file_get_contents(base_path('version')));
32 return view('settings.categories.' . $category, [
33 'category' => $category,
34 'version' => $version,
35 'guestUser' => User::getGuest(),
40 * Update the specified settings in storage.
42 public function update(Request $request, AppSettingsStore $store, string $category)
44 $this->ensureCategoryExists($category);
45 $this->preventAccessInDemoMode();
46 $this->checkPermission('settings-manage');
47 $this->validate($request, [
48 'app_logo' => ['nullable', ...$this->getImageValidationRules()],
49 'app_icon' => ['nullable', ...$this->getImageValidationRules()],
52 $store->storeFromUpdateRequest($request, $category);
53 $this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
55 return redirect("/settings/{$category}");
58 protected function ensureCategoryExists(string $category): void
60 if (!view()->exists('settings.categories.' . $category)) {