diff --git a/app/Http/Controllers/Admin/AdminSettingsController.php b/app/Http/Controllers/Admin/AdminSettingsController.php index 9e1a685cd..f1dfea652 100644 --- a/app/Http/Controllers/Admin/AdminSettingsController.php +++ b/app/Http/Controllers/Admin/AdminSettingsController.php @@ -8,12 +8,51 @@ use Carbon\Carbon; use App\{Comment, Like, Media, Page, Profile, Report, Status, User}; use App\Http\Controllers\Controller; use App\Util\Lexer\PrettyNumber; +use App\Models\ConfigCache; +use App\Services\ConfigCacheService; trait AdminSettingsController { public function settings(Request $request) { - return view('admin.settings.home'); + $name = ConfigCacheService::get('app.name'); + $short_description = ConfigCacheService::get('app.short_description'); + $description = ConfigCacheService::get('app.description'); + + return view('admin.settings.home', compact( + 'name', + 'short_description', + 'description' + )); + } + + public function settingsHomeStore(Request $request) + { + $this->validate($request, [ + 'name' => 'nullable|string', + 'short_description' => 'nullable', + 'long_description' => 'nullable' + ]); + + $cc = ConfigCache::whereK('app.name')->first(); + $val = $request->input('name'); + if($cc && $cc->v != $val) { + ConfigCacheService::put('app.name', $val); + } + + $cc = ConfigCache::whereK('app.short_description')->first(); + $val = $request->input('short_description'); + if($cc && $cc->v != $val) { + ConfigCacheService::put('app.short_description', $val); + } + + $cc = ConfigCache::whereK('app.description')->first(); + $val = $request->input('long_description'); + if($cc && $cc->v != $val) { + ConfigCacheService::put('app.description', $val); + } + + return redirect('/i/admin/settings'); } public function settingsBackups(Request $request) @@ -84,15 +123,6 @@ trait AdminSettingsController return view('admin.settings.features'); } - public function settingsHomeStore(Request $request) - { - $this->validate($request, [ - 'APP_NAME' => 'required|string', - ]); - // Artisan::call('config:clear'); - return redirect()->back(); - } - public function settingsPages(Request $request) { $pages = Page::orderByDesc('updated_at')->paginate(10); @@ -135,4 +165,4 @@ trait AdminSettingsController } return view('admin.settings.system', compact('sys')); } -} \ No newline at end of file +} diff --git a/resources/views/admin/settings/home.blade.php b/resources/views/admin/settings/home.blade.php index 59fdfbf11..fc0c2f345 100644 --- a/resources/views/admin/settings/home.blade.php +++ b/resources/views/admin/settings/home.blade.php @@ -3,61 +3,39 @@ @include('admin.settings.sidebar') @section('section') -
-

Settings

-
-
-
- @csrf -
- -
- -

Site name, default: pixelfed

-
-
-
- -
- -

App URL, used for building URLs ex: https://example.org

-
-
- -
- -
- -

Used for routing ex: example.org

-
-
+
+

Settings

+

Manage instance settings

+
+ + @csrf +
+
+ + +

The instance name used in titles, metadata and apis.

+
+
+
+
+ + +

Short description of instance used on various pages and apis.

+
+
+
+
+ + +

Longer description of instance used on about page.

+
+
-
- -
- -

Used for routing the admin dashboard ex: admin.example.org

-
-
- - {{--
-
-
- -
-
-

Tip:

-

You can edit the .env file in the Configuration settings.

-
-
-
- -
-
-
- -
-
--}} -
-@endsection \ No newline at end of file +
+
+ +
+
+ +@endsection