瀏覽代碼

fix: 🚑️ Icon uploading

IceToast 3 年之前
父節點
當前提交
e9e539c8c5
共有 2 個文件被更改,包括 19 次插入43 次删除
  1. 19 0
      app/Classes/Settings/System.php
  2. 0 43
      app/Http/Controllers/Admin/SettingsController.php

+ 19 - 0
app/Classes/Settings/System.php

@@ -42,6 +42,9 @@ class System
                 ->withInput();
         }
 
+        // update Icons from request
+        $this->updateIcons($request);
+
 
         $values = [
             "SETTINGS::SYSTEM:REGISTER_IP_CHECK" => "register-ip-check",
@@ -70,4 +73,20 @@ class System
         }
         return redirect(route('admin.settings.index') . '#system')->with('success', __('System settings updated!'));
     }
+
+    private function updateIcons(Request $request)
+    {
+        $request->validate([
+            'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg',
+            'favicon' => 'nullable|max:10000|mimes:ico',
+        ]);
+
+        if ($request->hasFile('icon')) {
+            $request->file('icon')->storeAs('public', 'icon.png');
+        }
+
+        if ($request->hasFile('favicon')) {
+            $request->file('favicon')->storeAs('public', 'favicon.ico');
+        }
+    }
 }

+ 0 - 43
app/Http/Controllers/Admin/SettingsController.php

@@ -40,47 +40,4 @@ class SettingsController extends Controller
             'tabListItems' => $tabListItems,
         ]);
     }
-
-
-    public function updatevalue(Request $request)
-    {
-        $setting = Settings::findOrFail($request->input('key'));
-
-        $request->validate([
-            'key'   => 'required|string|max:191',
-            'value' => 'required|string|max:191',
-        ]);
-
-        $setting->update($request->all());
-
-        return redirect()->route('admin.settings.index')->with('success', __('configuration has been updated!'));
-    }
-
-    /**
-     * Remove the specified resource from storage.
-     *
-     * @param Settings $setting
-     * @return Response
-     */
-    public function destroy(Settings $setting)
-    {
-        //
-    }
-
-    public function datatable()
-    {
-        $query = Settings::where('key', 'like', '%SYSTEM%')
-            ->orWhere('key', 'like', '%USER%')
-            ->orWhere('key', 'like', '%SERVER%');
-
-        return datatables($query)
-            ->addColumn('actions', function (Settings $setting) {
-                return '<button data-content="' . __("Edit") . '" data-toggle="popover" data-trigger="hover" data-placement="top" onclick="configuration.parse(\'' . $setting->key . '\',\'' . $setting->value . '\',\'' . $setting->type . '\')" data-content="Edit" data-trigger="hover" data-toggle="tooltip" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></button> ';
-            })
-            ->editColumn('created_at', function (Settings $setting) {
-                return $setting->created_at ? $setting->created_at->diffForHumans() : '';
-            })
-            ->rawColumns(['actions'])
-            ->make();
-    }
 }