/**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     $redirectUrl = Session::get('redirect_to', route('dashboard.settings.setup'));
     if (Binput::get('remove_banner') === '1') {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.too-big', ['size' => $maxSize]));
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::to($redirectUrl)->withErrors($file->getErrorMessage());
         }
         if (!starts_with($file->getMimeType(), 'image/')) {
             return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.app-setup.images-only'));
         }
         // 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()]);
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             if ($settingName === 'app_analytics_pi_url') {
                 $settingValue = rtrim($settingValue, '/');
             }
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::to($redirectUrl)->withErrors(trans('dashboard.settings.edit.failure'));
     }
     if (Binput::has('app_locale')) {
         Lang::setLocale(Binput::get('app_locale'));
     }
     return Redirect::to($redirectUrl)->withSuccess(trans('dashboard.settings.edit.success'));
 }
 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     if (Binput::get('remove_banner') == "1") {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::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}.");
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::back()->withErrorMessage($file->getErrorMessage());
         }
         if (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()]);
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::back()->withSaved(false);
     }
     return Redirect::back()->withSaved(true);
 }