Search code examples
phplaravelblogsoctobercms

How to get RainLab Blog plugin new post event?


I use RainLab.Blog plugin on my site running OctoberCMS. I want to send mails to users in my database, whenever I make new post in my blog. I know that I can use Laravel Notifications , but can't figure out how to attach it to new post event, if there is any.


Solution

  • Use model events: https://octobercms.com/docs/database/model#events

    You can use the Extend method on your model E.g: BlogNews::extend(function { ... }) and either use addDynamicMethod or implement a behaviour that has the event handler methods events you need.