Event idea in laravel [duplicate]

0

I'm developing a system in Laravel (php). I read in several articles that "we should" use the "EVENTS" to perform actions after the main has been done, eg
- > no controller:
// I register a user
// call event (store)

- > in the event store, has a listener for each item, eg:
// register in the specified user group. // send e-mail talking about registration.
// ...

Is the idea really this?

I thought it could be done as follows:
- > no controller
// call event store

- > no event store:
// register user
// register in the specified user group. // send e-mail talking about registration. // ..

    
asked by anonymous 08.06.2016 / 15:12

1 answer

0

Events must be used to perform functions when an action occurs on the system, the controller will be responsible for, for example, saving the model, so it triggers an event that can be called NovoModeloCriado , this way several event listeners can perform the actions, such as sending an e-mail, making statistical calculations in the database, creating a new record in another table related to the context of the saved template.

See the answer in link for more details on events and eloquenbt observers.

    
25.05.2017 / 14:29