Exemple #1
0
 public static function boot()
 {
     parent::boot();
     static::created(function (Task $task) {
         event(new NewTask($task));
     });
 }
 public static function boot()
 {
     parent::boot();
     static::created(function (EventLog $eventLog) {
         event(new NewEventLog($eventLog));
     });
 }
 public static function boot()
 {
     parent::boot();
     static::created(function (Notification $notification) {
         event(new NewNotification($notification));
     });
 }
Exemple #4
0
 public static function boot()
 {
     parent::boot();
     static::created(function (Post $post) {
         event(new NewPost($post));
     });
 }
 public static function boot()
 {
     parent::boot();
     static::created(function (Comment $comment) {
         event(new NewComment($comment));
         if ($post = $comment->post) {
             $post->commentCount += 1;
             $post->save();
         }
         if ($comment->parentCommentId && ($parent = $comment->parentComment)) {
             $parent->replyCount += 1;
             $parent->save();
         }
     });
     static::deleted(function (Comment $comment) {
         if ($post = $comment->post) {
             $post->commentCount -= 1;
             $post->save();
         }
         if ($comment->parentCommentId && ($parent = $comment->parentComment)) {
             $parent->replyCount -= 1;
             $parent->save();
         }
     });
 }
Exemple #6
0
 public static function boot()
 {
     parent::boot();
     static::created(function (Like $like) {
         event(new NewLike($like));
     });
 }
 public static function boot()
 {
     parent::boot();
     static::deleting(function (Submission $submission) {
         Post::where('submissionId', $submission->id)->delete();
     });
 }
 public static function boot()
 {
     parent::boot();
     static::saving(function (Category $category) {
         $category->parentCategoryId = $category->parentCategoryId ? (int) $category->parentCategoryId : null;
     });
 }
 public static function boot()
 {
     parent::boot();
     static::saving(function (Sticker $sticker) {
         $sticker->requiredTasks = $sticker->requiredTasks ? (int) $sticker->requiredTasks : null;
         Cache::forget('stickerSelectList');
     });
     static::created(function (Sticker $sticker) {
         event(new NewSticker($sticker));
     });
 }
 public static function boot()
 {
     parent::boot();
     self::created(function (StickerDesign $design) {
         // Set the sticker's design upon creation if one doesn't already exist
         $sticker = $design->sticker;
         if (!$sticker->designId) {
             $sticker->designId = $design->id;
             $sticker->save();
         }
     });
 }
Exemple #11
0
 /**
  * Add event listeners
  */
 public static function boot()
 {
     parent::boot();
     // Attach event handler, on deleting of the user
     self::deleting(function (User $user) {
         if ($profile = $user->profile) {
             $profile->delete();
         }
     });
     // Attach event handler, on creation of the user
     self::created(function (User $user) {
         $profile = new UserProfile();
         $user->profile()->save($profile);
         event(new NewUser($user));
     });
 }