To avoid changing lots of code in your controllers you could model it inside your Model and pick up on the ‘created’ or ‘updated’ events of the model, and then call subsequent events.
class Offer extends Model
{
protected static function booted()
{
static::updated(function ($user) {
// check for condition and trigger event such as OfferEditedBySeller
});
}
}
If you want to use event/listener architecture then I think one event and listener for ever notification is the way you have to go.
Alternatively, don’t bother with events/listeners – just send your notifications from the controller or from the ‘created’ or ‘updated’ events of the model. Cut out the middleman (events/listeners) and you’ll have more explicit code which is easier to follow.
Events/listeners are good when you need to decouple and abstract – but if you are doing explicit things then not using them might be simpler for you.
CLICK HERE to find out more related problems solutions.