/**
  * 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)]);
 }
 /**
  * Notifications
  *
  * @param Request $request
  * @return array|\Illuminate\View\View
  */
 public function all(Request $request)
 {
     $notifications = $this->notification->search($this->currentUser, 10);
     if ($request->has('ajax')) {
         return $this->jsonPagination($notifications, $this->view('ajax.notifications', compact('notifications')));
     }
     return $this->view('notifications.list', compact('notifications'));
 }
 /**
  * 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)]);
     }
 }