/var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Model/Table/SettingsTable.php (1783B)
setTable('settings');
$this->setDisplayField('name');
$this->setPrimaryKey('id');
}
public function getAllSettings()
{
$settings = [];
$result = $this->find()
->select(['Settings.name', 'Settings.value', 'Settings.type'])
->enableHydration(false)
->toArray();
foreach ($result as $row) {
if ($row['type'] == 'checkbox') {
$row['value'] = ($row['value'] === '1') ? '1' : '0';
}
$settings[$row['name']]['value'] = trim(strval($row['value']));
}
return $settings;
}
/**
* Default validation rules.
*/
public function validationDefault(Validator $validator): Validator
{
$validator
->integer('id')
->allowEmptyString('id', null, 'create');
$validator
->scalar('name')
->maxLength('name', 255)
->requirePresence('name', 'create')
->notEmptyString('name');
$validator
->scalar('value')
->maxLength('value', 255)
->requirePresence('value', 'create')
->notEmptyString('value');
$validator
->scalar('type')
->maxLength('type', 255)
->requirePresence('type', 'create')
->notEmptyString('type');
return $validator;
}
}