Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. namespace AppObservers;
  2.  
  3. class SubjectObserver {
  4.  
  5. private $shouldUpdateThreads = false;
  6.  
  7. /**
  8. * Listen to the ThreadList created event.
  9. * This events Fire when ThreadList is handled
  10. * @param AppObserversAppThreadList $threadList
  11. */
  12. public function created(subject $subject) {
  13.  
  14. }
  15.  
  16. /**
  17. * Listen to the ThreadList saved event.
  18. * @param AppObserversAppThreadList $threadList
  19. */
  20. public function saved(subject $subject) {
  21.  
  22. }
  23.  
  24. /**
  25. * Handling subject updated event
  26. * Used to update the threads and related models
  27. * @param subject $subject
  28. */
  29. public function updated(subject $subject) {
  30. info('After Update Event ' . $this->shouldUpdateThreads);
  31. if ($this->shouldUpdateThreads) {
  32. info_plus($subject);
  33. }
  34. info('After Update Check');
  35. }
  36.  
  37. /**
  38. * Handling subject being updated event
  39. * Used to check if the teachers data has changed or not
  40. * @param subject $subject
  41. */
  42. public function updating(subject $_subject) {
  43.  
  44. $subject = subject::find($_subject->id);
  45.  
  46. $this->shouldUpdateThreads = ($subject->teacherId != $_subject->teacherId) ? true : false;
  47.  
  48. info(($subject->teacherId != $_subject->teacherId));
  49.  
  50. info("Thread update ? " . $this->shouldUpdateThreads);
  51. }
  52.  
  53. public function deleted(subject $subject) {
  54. info("Subject deleted");
  55. }
  56.  
  57. }
  58.  
  59. $subject->getOriginal('teacher_id');
  60.  
  61. public function updated(subject $subject) {
  62. info('After Update Event ' . $this->shouldUpdateThreads);
  63. if ($subject->getOriginal('teacher_id') !== $subject->teacher_id) {
  64. info_plus($subject);
  65. }
  66. info('After Update Check');
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement