From 77913b59db7270233d0ff8196c06b1d4a531b82f Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 20 Dec 2014 17:50:47 +0000 Subject: [PATCH] Settings can now be updated --- app/controllers/DashboardController.php | 23 +++++++++++++++++ app/models/Setting.php | 2 ++ app/routes/dashboard.php | 1 + app/views/dashboard/settings.blade.php | 33 +++++++++++++------------ 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/app/controllers/DashboardController.php b/app/controllers/DashboardController.php index dfeb0a08..1f9a1875 100644 --- a/app/controllers/DashboardController.php +++ b/app/controllers/DashboardController.php @@ -116,4 +116,27 @@ class DashboardController extends Controller { 'pageTitle' => 'Settings - Dashboard' ]); } + + /** + * Updates the statsu page settings. + * @return \Illuminate\View\View + */ + public function postSettings() { + $settings = Input::all(); + + foreach ($settings as $settingName => $settingValue) { + // Don't save empty settings. Kinda useless... + if (!$settingValue) { + continue; + } + + $setting = Setting::firstOrCreate([ + 'name' => $settingName, + ])->update([ + 'value' => $settingValue + ]); + } + + return Redirect::back(); + } } diff --git a/app/models/Setting.php b/app/models/Setting.php index fcbbdfa9..9049d4e9 100644 --- a/app/models/Setting.php +++ b/app/models/Setting.php @@ -1,6 +1,8 @@ 'auth', 'prefix' => 'dashboard'], function() { Route::get('notifications', ['as' => 'dashboard.notifications', 'uses' => 'DashboardController@showNotifications']); Route::get('status-page', ['as' => 'dashboard.status-page', 'uses' => 'DashboardController@showStatusPage']); Route::get('settings', ['as' => 'dashboard.settings', 'uses' => 'DashboardController@showSettings']); + Route::post('settings', 'DashboardController@postSettings'); }); diff --git a/app/views/dashboard/settings.blade.php b/app/views/dashboard/settings.blade.php index 6e4df75c..85bbc571 100644 --- a/app/views/dashboard/settings.blade.php +++ b/app/views/dashboard/settings.blade.php @@ -6,16 +6,16 @@
-
-

Cachet Settings Not working yet.

+ +

Cachet Settings

- +
- +
@@ -28,11 +28,11 @@
- +
- +
@@ -44,26 +44,27 @@

Theme

- - + +
- - + +
- - + +
- - + +
- - + +
+