feat: ✨ Persist settings in DB on update
This commit is contained in:
parent
c3420b1684
commit
7f8017de76
|
@ -73,9 +73,6 @@ class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
$category = request()->get('category');
|
$category = request()->get('category');
|
||||||
|
|
||||||
error_log($category);
|
|
||||||
|
|
||||||
|
|
||||||
$className = 'App\\Settings\\' . $category . 'Settings';
|
$className = 'App\\Settings\\' . $category . 'Settings';
|
||||||
if (method_exists($className, 'getValidations')) {
|
if (method_exists($className, 'getValidations')) {
|
||||||
$validations = $className::getValidations();
|
$validations = $className::getValidations();
|
||||||
|
@ -89,6 +86,15 @@ class SettingsController extends Controller
|
||||||
return Redirect::to('admin/settings' . '#' . $category)->withErrors($validator)->withInput();
|
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.');
|
return Redirect::to('admin/settings' . '#' . $category)->with('success', 'Settings updated successfully.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue