2014-12-20 21:20:17 +00:00
|
|
|
<?php
|
2014-12-20 18:53:52 +00:00
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
class DashSettingsController extends Controller
|
|
|
|
{
|
2014-12-31 10:38:59 +00:00
|
|
|
protected $subMenu = [];
|
|
|
|
protected $subTitle = 'Settings';
|
|
|
|
|
2014-12-31 11:39:28 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2014-12-31 10:38:59 +00:00
|
|
|
$this->subMenu = [
|
|
|
|
'setup' => [
|
|
|
|
'title' => 'Application Setup',
|
|
|
|
'url' => '/dashboard/settings/setup',
|
|
|
|
'icon' => 'ion-gear-b',
|
|
|
|
'active' => false,
|
|
|
|
],
|
|
|
|
'security' => [
|
|
|
|
'title' => 'Security',
|
|
|
|
'url' => '/dashboard/settings/security',
|
|
|
|
'icon' => 'ion-lock-combination',
|
|
|
|
'active' => false,
|
|
|
|
],
|
|
|
|
'theme' => [
|
|
|
|
'title' => 'Theme',
|
|
|
|
'url' => '/dashboard/settings/theme',
|
|
|
|
'icon' => 'ion-paintbrush',
|
|
|
|
'active' => false,
|
|
|
|
],
|
|
|
|
'stylesheet' => [
|
|
|
|
'title' => 'Stylesheet',
|
|
|
|
'url' => '/dashboard/settings/stylesheet',
|
|
|
|
'icon' => 'ion-paintbucket',
|
|
|
|
'active' => false,
|
2014-12-31 11:39:28 +00:00
|
|
|
],
|
2014-12-31 10:38:59 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
View::share('subTitle', $this->subTitle);
|
|
|
|
View::share('subMenu', $this->subMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the settings setup view.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showSetupView()
|
|
|
|
{
|
|
|
|
$this->subMenu['setup']['active'] = true;
|
|
|
|
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.settings.app-setup')->with([
|
2014-12-31 10:38:59 +00:00
|
|
|
'pageTitle' => 'Application Setup - Dashboard',
|
2014-12-31 11:39:28 +00:00
|
|
|
'subMenu' => $this->subMenu,
|
2014-12-31 10:38:59 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the settings theme view.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showThemeView()
|
|
|
|
{
|
|
|
|
$this->subMenu['theme']['active'] = true;
|
|
|
|
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.settings.theme')->with([
|
2014-12-31 10:38:59 +00:00
|
|
|
'pageTitle' => 'Theme - Dashboard',
|
2014-12-31 11:39:28 +00:00
|
|
|
'subMenu' => $this->subMenu,
|
2014-12-31 10:38:59 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the settings security view.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function showSecurityView()
|
|
|
|
{
|
|
|
|
$this->subMenu['security']['active'] = true;
|
|
|
|
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.settings.security')->with([
|
2014-12-31 10:38:59 +00:00
|
|
|
'pageTitle' => 'Security - Dashboard',
|
2014-12-31 11:39:28 +00:00
|
|
|
'subMenu' => $this->subMenu,
|
2014-12-31 10:38:59 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
/**
|
2014-12-31 10:38:59 +00:00
|
|
|
* Shows the settings stylesheet view.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2014-12-31 10:38:59 +00:00
|
|
|
public function showStylesheetView()
|
2014-12-20 21:20:17 +00:00
|
|
|
{
|
2014-12-31 10:38:59 +00:00
|
|
|
$this->subMenu['stylesheet']['active'] = true;
|
|
|
|
|
2015-01-01 10:39:22 +00:00
|
|
|
return View::make('dashboard.settings.stylesheet')->with([
|
2014-12-31 10:38:59 +00:00
|
|
|
'pageTitle' => 'Stylesheet - Dashboard',
|
2014-12-31 11:39:28 +00:00
|
|
|
'subMenu' => $this->subMenu,
|
2014-12-20 21:20:17 +00:00
|
|
|
]);
|
|
|
|
}
|
2014-12-20 18:53:52 +00:00
|
|
|
|
2014-12-20 21:20:17 +00:00
|
|
|
/**
|
2014-12-31 11:45:54 +00:00
|
|
|
* Updates the status page settings.
|
2014-12-29 23:07:46 +00:00
|
|
|
*
|
2014-12-20 21:20:17 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
|
|
|
public function postSettings()
|
|
|
|
{
|
2014-12-23 10:17:30 +00:00
|
|
|
// Fetch all of the settings we've been POSTed.
|
2014-12-20 21:20:17 +00:00
|
|
|
$settings = Input::all();
|
2014-12-20 18:53:52 +00:00
|
|
|
|
2014-12-31 11:45:54 +00:00
|
|
|
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([
|
2014-12-31 11:51:06 +00:00
|
|
|
'name' => 'app_banner',
|
2014-12-31 11:45:54 +00:00
|
|
|
])->update([
|
2014-12-31 11:51:06 +00:00
|
|
|
'value' => base64_encode(file_get_contents($file->getRealPath())),
|
2014-12-31 11:45:54 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Store the banner type
|
|
|
|
Setting::firstOrCreate([
|
2014-12-31 11:51:06 +00:00
|
|
|
'name' => 'app_banner_type',
|
2014-12-31 11:45:54 +00:00
|
|
|
])->update([
|
2014-12-31 11:51:06 +00:00
|
|
|
'value' => $file->getMimeType(),
|
2014-12-31 11:45:54 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($settings['app_banner']);
|
|
|
|
|
2014-12-31 10:38:59 +00:00
|
|
|
try {
|
|
|
|
foreach ($settings as $settingName => $settingValue) {
|
|
|
|
$setting = Setting::firstOrCreate([
|
|
|
|
'name' => $settingName,
|
|
|
|
])->update([
|
|
|
|
'value' => $settingValue,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
return Redirect::back()->withSaved(false);
|
2014-12-20 21:20:17 +00:00
|
|
|
}
|
2014-12-20 18:53:52 +00:00
|
|
|
|
2014-12-31 10:38:59 +00:00
|
|
|
return Redirect::back()->withSaved(true);
|
2014-12-20 21:20:17 +00:00
|
|
|
}
|
2014-12-20 18:53:52 +00:00
|
|
|
}
|