['value' => '#4F46E5', 'group' => 'ui', 'type' => 'string'], 'ui_logo_url' => ['value' => '', 'group' => 'ui', 'type' => 'string'], 'helper_enabled' => ['value' => '1', 'group' => 'helper', 'type' => 'boolean'], 'game_enabled' => ['value' => '0', 'group' => 'game', 'type' => 'boolean'], 'questionnaire_url' => ['value' => '', 'group' => 'game', 'type' => 'string'], ]; foreach ($defaults as $key => $data) { AppConfig::firstOrCreate(['key' => $key], $data); } $configs = AppConfig::all()->groupBy('group'); return view('admin.app-configs.index', compact('configs')); } public function update(Request $request) { $data = $request->except('_token', '_method'); foreach ($data as $key => $value) { AppConfig::updateOrCreate( ['key' => $key], ['value' => $value] ); } return redirect()->back()->with('success', '設定已更新'); } }