3 namespace BookStack\Settings;
5 use BookStack\Activity\ActivityType;
6 use BookStack\App\AppVersion;
7 use BookStack\Http\Controller;
8 use BookStack\Users\Models\User;
9 use Illuminate\Http\Request;
11 class SettingController extends Controller
14 * Handle requests to the settings index path.
16 public function index()
18 return redirect('/settings/features');
22 * Display the settings for the given category.
24 public function category(string $category)
26 $this->ensureCategoryExists($category);
27 $this->checkPermission('settings-manage');
28 $this->setPageTitle(trans('settings.settings'));
30 return view('settings.categories.' . $category, [
31 'category' => $category,
32 'version' => AppVersion::get(),
33 'guestUser' => User::getGuest(),
38 * Update the specified settings in storage.
40 public function update(Request $request, AppSettingsStore $store, string $category)
42 $this->ensureCategoryExists($category);
43 $this->preventAccessInDemoMode();
44 $this->checkPermission('settings-manage');
45 $this->validate($request, [
46 'app_logo' => ['nullable', ...$this->getImageValidationRules()],
47 'app_icon' => ['nullable', ...$this->getImageValidationRules()],
50 $store->storeFromUpdateRequest($request, $category);
51 $this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
53 return redirect("/settings/{$category}");
56 protected function ensureCategoryExists(string $category): void
58 if (!view()->exists('settings.categories.' . $category)) {