Extend user module with additional fields and functions
I want to extend the USER module to 2 purposes:
- add additional fields
- make relationship as well as actions like CRUD, make my project specific functions with users
So I am considering these options below:
- overwrite USER module (which make me not able to update CMS anymore)
- Add more fields into users table, and use event to update and show the additional fields (Not sure that event can help for all cases)
- Create new module (ex: PROFILE module) which has additional fields and I can easy to make my specific functions because I have my own controller, repository, model so that will let the core USER module untouched. But this will make the relationship more complicated, and the query need to joined more table.
The above options have pros and cons. Therefore, I need your help to determine which is best practice to extend user module in AsgardCMS.
Thank you very much,
It all depends on how much and what kind of functionality you would like to add.
For something like extra fields and mild modification the extension of a User module is the way to go.
Relationships in this kind of approach are really no different for the most part as any other relation (you have
profilerelation on user and
userrelation on profile).
You can even rewrite some of User files through route overriding (like registration logic etc.).
Obviously, most freedom would be using your own fork of User module ( you can update cms just fine, except you will have to manually update your forked User module).
Events approach is most frustrating to deal with, to be honest, would not recommend that.