diff --git a/app/controllers/DashSettingsController.php b/app/controllers/DashSettingsController.php index 01fbf1b7..664edbc0 100644 --- a/app/controllers/DashSettingsController.php +++ b/app/controllers/DashSettingsController.php @@ -99,7 +99,7 @@ class DashSettingsController extends Controller } /** - * Updates the statsu page settings. + * Updates the status page settings. * * @return \Illuminate\View\View */ @@ -108,6 +108,37 @@ class DashSettingsController extends Controller // Fetch all of the settings we've been POSTed. $settings = Input::all(); + if (Input::hasFile('app_banner')) { + $file = Input::file('app_banner'); + + // Image Validation. + // Image size in bytes. + $maxSize = $file->getMaxFilesize(); + if ($file->getSize() > $maxSize) { + return Redirect::back()->withErrorMessage('You need to upload an image that is less than '.$maxSize.'.'); + } elseif (!$file->isValid() || $file->getError()) { + return Redirect::back()->withErrorMessage($file->getErrorMessage()); + } elseif (strpos($file->getMimeType(), 'image/') !== 0) { + return Redirect::back()->withErrorMessage('Only images may be uploaded.'); + } + + // Store the banner. + Setting::firstOrCreate([ + 'name' => 'app_banner' + ])->update([ + 'value' => base64_encode(file_get_contents($file->getRealPath())) + ]); + + // Store the banner type + Setting::firstOrCreate([ + 'name' => 'app_banner_type' + ])->update([ + 'value' => $file->getMimeType() + ]); + } + + unset($settings['app_banner']); + try { foreach ($settings as $settingName => $settingValue) { $setting = Setting::firstOrCreate([ diff --git a/app/views/dashboard/settings-app-setup.blade.php b/app/views/dashboard/settings-app-setup.blade.php index 8912f6d5..86a43c66 100644 --- a/app/views/dashboard/settings-app-setup.blade.php +++ b/app/views/dashboard/settings-app-setup.blade.php @@ -13,13 +13,13 @@
-
+

Application Setup

- @if($saved = Session::get('saved')) + @if(($saved = Session::get('saved')))
{{ Lang::get('cachet.dashboard.settings_saved') }}
- @elseif(Session::has('saved')) -
{{ Lang::get('cachet.dashboard.settings_not_saved') }}
+ @elseif(Session::has('error_message')) +
{{ Session::get('error_message') }}
@endif
@@ -39,6 +39,20 @@
+
+
+
+ + @if($banner = Setting::get('app_banner')) +
+ +
+ @endif + + It's recommended that you upload files no bigger than 930px wide. +
+
+
diff --git a/app/views/index.blade.php b/app/views/index.blade.php index a8759408..421a8f16 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -1,6 +1,15 @@ @extends('layout.master') @section('content') + @if($bannerImage = Setting::get('app_banner')) +
+
+ + +
+
+ @endif +
{{ $systemMessage }}
@include('partials.components')