Difference between Events and Notifications in Laravel
We can fire an event and broadcast it to laravel echo from that event. The same can be done with Notifications viaBroadcast so what is the difference? Let’s find out. In any app like Facebook, Instagram their will be notifications when you login and you will also get relevant notification mails. Laravel Notifications are also similar to this. Using notify method on eloquent models such as App/User about anything like OrderDelivered which will do what you wanted to do like send sms to user. You can save the instant of that notification in the database so that the user can see notifications when logged in.
When something happens like a new user is added and you want to perform multiple tasks like send sms, send a verification mail etc you can create an event and handle these tasks using listeners. To broadcast these use ShouldBroadcast interface on your event so that you can sync data with admin panel from there that a new user is added. You can append the new user using Laravel Echo while the admin is watching the user list.
Comments
0 comments
Please Sign in or Create an account to Post Comments