Nahid\Talk\Conversations\ConversationRepository::getMessagesById PHP Метод

getMessagesById() публичный Метод

* get all conversations by given conversation id
public getMessagesById ( $conversationId, $offset, $take )
$conversationId
$offset
$take
    public function getMessagesById($conversationId, $offset, $take)
    {
        return $this->with(['messages' => function ($q) use($offset, $take) {
            $q->offset($offset);
            $q->take($take);
        }, 'userone', 'usertwo'])->find($conversationId);
    }

Same methods

ConversationRepository::getMessagesById ( $conversationId, $userId, $offset, $take )

Usage Example

Пример #1
0
 /**
  * fetch all conversation by using coversation id.
  *
  * @param int $conversationId
  * @param int $offset = 0
  * @param int $take = 20
  * @return \Nahid\Talk\Messages\Message
  */
 public function getConversationsById($conversationId, $offset = 0, $take = 20)
 {
     $conversations = $this->conversation->getMessagesById($conversationId, $offset, $take);
     $collection = (object) null;
     if ($conversations->user_one == $this->authUserId || $conversations->user_two == $this->authUserId) {
         $withUser = $conversations->userone->id === $this->authUserId ? $conversations->usertwo : $conversations->userone;
         $collection->withUser = $withUser;
         $collection->messages = $conversations->messages;
         return $collection;
     }
     return false;
 }
All Usage Examples Of Nahid\Talk\Conversations\ConversationRepository::getMessagesById