1. Go to this page and download the library: Download marksihor/laravel-messaging 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/ */
namespace App\User;
<...>
use MarksIhor\LaravelMessaging\Traits\Messageable;
class User extends Authenticatable
{
<...>
use Messageable;
<...>
}
$user()->chats; // get all chats available for given user (with last message)
$user()->chatsUnread; // get all unread chats
$user()->chatsRead; // get all read chats
$user()->chat(1); // get one chat with all messages
$user()->sendMessageToChat(1, ['text' => 'message to chat']); // send message to specified chat (if user is in the chat)
$user()->sendMessageToUser($recipient, ['text' => 'message to user', 'link' => 'https://some.link']); // send message to specified recipient