toArray(); if (method_exists($className, 'getOptionInputData')) { $optionInputData = $className::getOptionInputData(); } else { $optionInputData = []; } $optionsData = []; foreach ($options as $key => $value) { $optionsData[$key] = [ 'value' => $value, 'label' => $optionInputData[$key]['label'] ?? ucwords(str_replace('_', ' ', $key)), 'type' => $optionInputData[$key]['type'] ?? 'string', 'description' => $optionInputData[$key]['description'] ?? '', 'options' => $optionInputData[$key]['options'] ?? [], ]; } $settings[str_replace('Settings.php', '', $file)] = $optionsData; } $settings->sort(); $themes = array_diff(scandir(base_path('themes')), array('..', '.')); return view('admin.settings.index', [ 'settings' => $settings->all(), 'themes' => $themes, 'active_theme' => Theme::active(), ]); } /** * Update the specified resource in storage. * */ public function update(Request $request) { $category = request()->get('category'); $className = 'App\\Settings\\' . $category . 'Settings'; if (method_exists($className, 'getValidations')) { $validations = $className::getValidations(); } else { $validations = []; } $validator = Validator::make($request->all(), $validations); if ($validator->fails()) { return Redirect::to('admin/settings' . '#' . $category)->withErrors($validator)->withInput(); } $settingsClass = new $className(); foreach ($request->all() as $key => $value) { if ($key === '_token' || $key === 'category') continue; $settingsClass->$key = $value; } $settingsClass->save(); return Redirect::to('admin/settings' . '#' . $category)->with('success', 'Settings updated successfully.'); } }