NotificationObserver.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Observers;
  3. use App\Notification;
  4. use App\Services\NotificationService;
  5. class NotificationObserver
  6. {
  7. /**
  8. * Handle the notification "created" event.
  9. *
  10. * @param \App\Notification $notification
  11. * @return void
  12. */
  13. public function created(Notification $notification)
  14. {
  15. NotificationService::set($notification->profile_id, $notification->id);
  16. }
  17. /**
  18. * Handle the notification "updated" event.
  19. *
  20. * @param \App\Notification $notification
  21. * @return void
  22. */
  23. public function updated(Notification $notification)
  24. {
  25. NotificationService::set($notification->profile_id, $notification->id);
  26. }
  27. /**
  28. * Handle the notification "deleted" event.
  29. *
  30. * @param \App\Notification $notification
  31. * @return void
  32. */
  33. public function deleted(Notification $notification)
  34. {
  35. NotificationService::del($notification->profile_id, $notification->id);
  36. }
  37. /**
  38. * Handle the notification "restored" event.
  39. *
  40. * @param \App\Notification $notification
  41. * @return void
  42. */
  43. public function restored(Notification $notification)
  44. {
  45. NotificationService::set($notification->profile_id, $notification->id);
  46. }
  47. /**
  48. * Handle the notification "force deleted" event.
  49. *
  50. * @param \App\Notification $notification
  51. * @return void
  52. */
  53. public function forceDeleted(Notification $notification)
  54. {
  55. NotificationService::del($notification->profile_id, $notification->id);
  56. }
  57. }