Guillermo - path edit-settings[skip ci]

This commit is contained in:
AntonyAntonio 2016-12-14 22:27:31 -03:00
parent 0000fe5159
commit da2373e013
1 changed files with 24 additions and 62 deletions

View File

@ -4,75 +4,37 @@ use Respect\Validation\Validator as DataValidator;
class EditSettingsController extends Controller {
const PATH = '/edit-settings';
private $setting;
public function validations() {
return[
return [
'permission' => 'staff_3',
'requestData' => [
'name' => [
'validation' => DataValidator::length(4),
'error' => ERRORS::INVALID_SETTING
],
]
'requestData' => []
];
}
public function handler() {
$this->setting = Setting::getSetting(Controller::request('name'));
$this->editInformation();
$settings = [
'manteniance-mode',
'system-title',
'timezone',
'layout',
'smtp-server',
'smtp-email',
'smtp-password',
'smtp-port',
'default-language',
'recaptcha-public',
'recaptcha-private',
'allow-attachments',
'max-size'
];
foreach($settings as $setting) {
if(Controller::request($setting)) {
$settingInstance = Setting::getSetting($setting);
$settingInstance->value = Controller::request($setting);
$settingInstance->store();
}
}
Response::respondSuccess();
}
public function editInformation() {
if(Controller::request('manteniance-mode')) {
$this->setting->manteniance_mode = Controller::request('manteniance-mode');
}
if(Controller::request('system-title')) {
$this->setting->system_title = Controller::request('system-title');
}
if(Controller::request('timezone')) {
$this->setting->timezone = Controller::request('timezone');
}
if(Controller::request('layout')) {
$this->setting->layout = Controller::request('layout');
}
if(Controller::request('smtp-server')) {
$this->setting->smtp_server = Controller::request('smtp-server');
}
if(Controller::request('smtp-email')) {
$this->setting->smtp_email = Controller::request('smtp-email');
}
if(Controller::request('smtp-password')) {
$this->setting->smtp_password = Controller::request('smtp-password');
}
if(Controller::request('smtp-port')) {
$this->setting->smtp_port = Controller::request('smtp-port');
}
if(Controller::request('default-language')) {
$this->setting->default_language = Controller::request('default-language');
}
if(Controller::request('recaptcha-public')) {
$this->setting->recaptcha_public = Controller::request('recaptcha-public');
}
if(Controller::request('recaptcha-private')) {
$this->setting->sharedDepartmentList = Controller::request('recaptcha-private');
}
if(Controller::request('allow-attachments')) {
$this->setting->allow_attachments = Controller::request('allow-attachments');
}
if(Controller::request('max-size')) {
$this->setting->max_size = Controller::request('max-size');
}
$this->setting->store();
}
}