S
S
Sanes2020-12-12 10:46:51
Laravel
Sanes, 2020-12-12 10:46:51

Is this chain of events correct?

Task :
When adding a new user, create related entries in other tables.

  1. in UserObserver created I place a call to the UserCreatedEvent event
  2. Listeners for UserCreatedEvent perform necessary actions

Not too many moves? Maybe there is an easier solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2020-12-12
@Sanes

I would do in obsever. It is created for model events and it is convenient to maintain. Instead of riveting 60 events, 500 listeners on 10 models and then raking the provider. Especially if the logic does not provide that some of the listeners can return false and stop the execution of the event. In $dispatchesEvent I wouldn't remove it either. In general, it is not clear why they came up with this when there is an Observer. In the model, IMHO, there are so many things to launch events for yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question