chg: [user] virtual field for user settings

pull/72/head
Sami Mokaddem 2021-10-08 16:51:54 +02:00
parent 0b9b54f14a
commit b96991cf4a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,20 @@ use Authentication\PasswordHasher\DefaultPasswordHasher;
class User extends AppModel
{
protected $_hidden = ['password', 'confirm_password'];
protected $_virtual = ['user_settings_by_name'];
protected function _getUserSettingsByName()
{
$settingsByName = [];
if (!empty($this->user_settings)) {
foreach ($this->user_settings as $i => $setting) {
$settingsByName[$setting->name] = $setting;
}
}
return $settingsByName;
}
protected function _setPassword(string $password) : ?string
{
if (strlen($password) > 0) {