.. _server-account-settings: Account settings ================ Often it is necessary to create user account settings for modules. You can do that by extending the User entity with properties. Create a new property model. For example: .. code:: php addTable("addressbook_user_settings", "abs"); } } Also create a database table for it: .. code:: sql CREATE TABLE IF NOT EXISTS `addressbook_user_settings` ( `userId` int(11) NOT NULL, `defaultAddressBookId` int(11) DEFAULT NULL, PRIMARY KEY (`userId`), KEY `defaultAddressBookId` (`defaultAddressBookId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=COMPACT; ALTER TABLE `addressbook_user_settings` ADD CONSTRAINT `addressbook_user_settings_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `core_user` (`id`) ON DELETE CASCADE, ADD CONSTRAINT `addressbook_user_settings_ibfk_2` FOREIGN KEY (`defaultAddressBookId`) REFERENCES `addressbook_addressbook` (`id`) ON DELETE SET NULL; In the Module.php we can use the "Property::EVENT_MAPPING" :ref:`event ` to dynamically extend the User entity with this property: .. code:: php addRelation('addressBookSettings', UserSettings::class, ['id' => 'userId'], false); } } After these changes you must run install/upgrade.php to rebuild the cache. Now the User entity has this new property: .. code:: json { id: 1, username: "admin", addressBookSettings: { defaultAddressBookId: 1 } etc.. } You can now :ref:`implement a settings panel in the webclient `.