I need to send notification to some services based on type of created new model. Beacuse of there are many models in application I can't create event/listener code pair for every model in system. Is it posible to create event listener to every models in one place, or is it posible to intercept this action somehow?
Asked
Active
Viewed 86 times
0
-
If its a creation of a new data in that model you can use ļaravel observers – rakesh shrestha Dec 09 '18 at 02:38
-
No new data I need event when new model is created and saved to database. – Milos Dec 09 '18 at 02:51
-
@Milos, he is still right, what you are looking for is an Observer. There is a question for this already in place around stackoverflow. You can have a look in [here](https://stackoverflow.com/questions/39267139/how-to-practically-use-the-observer-pattern-in-laravel). Think it will give you a good insight :) – Diogo Santo Dec 09 '18 at 03:07