jeudi 25 juin 2020

PHP Design Pattern for checking if a class should be executed

I've developed a Laravel-based app that sends out various emails such as informing users of new jobs as well as new messages.

I have created all the necessary Mail classes. We now want to create a database column that will allow individual users to set whether they want to receive those notification emails or not.

When a user performs an action that would normally send out an email, I want the system to check if the user wants to receive those emails based on their settings in the database. I don't want to wrap all calls to email, in the code, with unnecessary if() functions.

Is there a preferred design pattern that I could use to handle this?

Aucun commentaire:

Enregistrer un commentaire