/** * Handle the event. * * @param PostWasVoted $event * @return void */ public function handle(PostWasVoted $event) { if ($event->value != 1 || $event->user->id == $event->post->user_id) { return; } $this->notification->create(['from_id' => $event->user->id, 'user_id' => $event->post->user_id, 'type' => 'post.like', 'url' => route('post', $event->post->slug)]); }
/** * Handle the event. * * @param CommentWasCreated $event * @return void */ public function handle(CommentWasCreated $event) { if ($event->user->id == $event->post->user_id || $event->comment->parent_id && $event->comment->parent->user_id == $event->user->id) { return; } // Notification to post author $this->notification->create(['from_id' => $event->user->id, 'user_id' => $event->post->user_id, 'type' => 'comment', 'url' => route('post', $event->post->slug)]); if ($event->comment->parent_id) { $this->notification->create(['from_id' => $event->user->id, 'user_id' => $event->comment->parent->user_id, 'type' => 'reply', 'url' => route('post', $event->post->slug)]); } }