/**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $actor = $request->getAttribute('actor');
     $actor->moderatorNotes_read_time = time();
     $actor->save();
     return ModeratorNotes::whereVisibleTo($actor)->with($this->extractInclude($request))->latest('moderatorNotes.time')->groupBy('post_id')->get();
 }
 /**
  * @param User $actor
  *
  * @return int
  */
 protected function getNewModeratorNotesCount(User $actor)
 {
     $query = ModeratorNotes::whereVisibleTo($actor);
     if ($time = $actor->moderatorNotes_read_time) {
         $query->where('moderatorNotes.time', '>', $time);
     }
     return $query->distinct()->count('moderatorNotes.post_id');
 }