public function conversationsWithNewMessages()
 {
     $conversationsWithNewMessages = [];
     $participants = \Andheiberg\Messenger\Models\Participant::where('user_id', $this->id)->lists('last_read', 'conversation_id');
     if ($participants) {
         $conversations = \Andheiberg\Messenger\Models\Conversation::whereIn('id', array_keys($participants))->get();
         foreach ($conversations as $conversation) {
             if ($conversation->updated_at > $participants[$conversation->id]) {
                 $conversationsWithNewMessages[] = $conversation->id;
             }
         }
     }
     return $conversationsWithNewMessages;
 }
 /**
  * addUser
  *
  * adds users to this conversation
  *
  * @param array $participantEmails list of all participants
  * @return void
  */
 public function addParticipants(array $participants)
 {
     $userModel = Config::get('messenger::user_model');
     $userModel = new $userModel();
     $participant_ids = [];
     if (is_array($participants)) {
         if (is_numeric($participants[0])) {
             $participant_ids = $participants;
         } else {
             $participant_ids = $userModel->whereIn('email', $participants)->lists('id');
         }
     } else {
         if (is_numeric($participants)) {
             $participant_ids = [$participants];
         } else {
             $participant_ids = $userModel->where('email', $participants)->lists('id');
         }
     }
     if (count($participant_ids)) {
         foreach ($participant_ids as $user_id) {
             Participant::create(['user_id' => $user_id, 'conversation_id' => $this->id]);
         }
     }
 }