vendredi 9 juillet 2021

Each role performs the same action differentyl

I have different user roles, each role can perform action which is creating record in db, but each role must apply additional features. For example: Admin just creates record in db. Role1 - creates record and syncs manyToMany relation Role2 - creates record and notification is sent etc.

I'm looking for some convinient way, like architectural pattern to resolve this case.

I was thinking about creating contract for my Admin, Role1, Role2 models and they would implement their own way of creating a record. My second idea was some kind of builder which could resolve user's role and apply some additional actions but it looks 'ify'.

Any idea?

Aucun commentaire:

Enregistrer un commentaire