Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function create(array $details)
 {
     $conversation = null;
     $this->dbManager->transaction(function () use($details, &$conversation) {
         $conversation = $this->conversationModel->create(['title' => $details['title']]);
         $this->conversationMessageRepository->addMessageToConversation($conversation, ['author_id' => $this->guard->user()->id, 'message' => $details['message']], false);
         // First add the author of this message - if he answered it he also read the conversation
         $conversation->participants()->attach($this->guard->user()->id, ['last_read' => new \DateTime()]);
         // And now add all other participants
         $this->addParticipants($conversation, $details['participants']);
     });
     return $conversation;
 }