PHP code example of dominservice / conversations
1. Go to this page and download the library: Download dominservice/conversations library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dominservice / conversations example snippets
'providers' => [
Dominservice\Conversations\ConversationsServiceProvider::class,
],
(...)
'aliases' => [
'Conversations' => Dominservice\Conversations\Facade\Conversations::class,
]
$convs = (new Dominservice\Conversations\Conversations)->create($users, $relationType = null, $relationId = null, $content = null, $getObject = false);
$convs = conversation_create($users, $relationType = null, $relationId = null, $content = null, $getObject = false);
$messageId = (new Dominservice\Conversations\Conversations)->addMessageOrCreateConversation($users, $content, $relationType = null, $relationId = null);
$messageId = conversation_add_or_create($users, $content, $relationType = null, $relationId = null);
$messageId = (new Dominservice\Conversations\Conversations)->addMessage($convUuid, $content, $addUser = false);
$messageId = conversation_add_message($convUuid, $content, $addUser = false);
$conversationId = (new Dominservice\Conversations\Conversations)->getIdBetweenUsers(array $users, $relationType = null, $relationId = null);
$conversationId = conversation_id_between($users, $relationType = null, $relationId = null);
$existsUser = (new Dominservice\Conversations\Conversations)->existsUser($convUuid, $userId);
$existsUser = conversation_user_exists($convUuid, $userId = null);
$count = (new Dominservice\Conversations\Conversations)->getUnreadCount($userId);
$count = conversation_unread_count($userId = null);
$count = (new Dominservice\Conversations\Conversations)->getConversationUnreadCount($convUuid, $userId);
$count = conversation_unread_count_per_id($convUuid, $userId = null);
(new Dominservice\Conversations\Conversations)->delete($convUuid, $userId);
conversation_delete($convUuid, $userId = null);
$conversations = (new Dominservice\Conversations\Conversations)->getConversations($userId, $relationType = null, $relationId = null);
foreach ( $conversations as $conv ) {
$getNumOfUsers = $conv->getNumOfUsers();
$users = $conv->users; /* Collection */
/* $lastMessage Dominservice\Conversations\Entities\Message */
$lastMessage = $conv->getLastMessage();
$senderId = $lastMessage->sender;
$content = $lastMessage->content;
$status = $lastMessage->status;
}
$conversations = conversations($userId = null, $relationType = null, $relationId = null, $withUsersList = true);
$messages = (new Dominservice\Conversations\Conversations)->getMessages($convUuid, $userId, $newToOld = true, $limit = null, $start = null);
$messages = conversation_messages($convUuid, $userId = null, $newToOld = true, $limit = null, $start = null);
$messages = (new Dominservice\Conversations\Conversations)->getUnreadMessages($convUuid, $userId, $newToOld = true, $limit = null, $start = null);
$messages = conversation_messages_unread($convUuid, $userId = null, $newToOld = true, $limit = null, $start = null);
conversation_mark_as_archived($convUuid, $msgId, $userId = null);
conversation_mark_as_deleted($convUuid, $msgId, $userId = null);
conversation_mark_as_unread($convUuid, $msgId, $userId = null);
conversation_mark_as_read($convUuid, $msgId, $userId = null);
conversation_mark_as_read_all($convUuid, $userId = null);
conversation_mark_as_unread_all($convUuid, $userId = null);
public function conversations() {
$currentUser = Auth::user();
//get the conversations
$conversations = conversations($currentUser->id);
//array for storing our users data, as that Conversations only provides user id's
$users = collect();
//gathering users
foreach ( $conversations as $conv ) {
$users->push($conv->users);
}
//making sure each user appears once
$users = $users->unique();
return View::make('conversations_page')
->with('users', $users)
->with('user', $currentUser)
->with('conversations', $conversations);
}
php artisan vendor:publish --provider="Dominservice\Conversations\ConversationsServiceProvider"
php artisan migrate