1. Go to this page and download the library: Download dominservice/laravel_chat 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/ */
public function conversations($convId=null) {
$currentUser = Auth::user();
//get the conversations
$convs = LaravelChat::getConversations( $currentUser->id );
//array for storing our users data, as that LaravelChat only provides user id's
$users = [];
//gathering users
foreach ( $convs as $conv ) {
$users = array_merge($users, $conv->getAllUsers());
}
//making sure each user appears once
$users = array_unique($users);
//getting all data of users
if ( !empty($users) ) {
$users = User::whereIn('id', $users)->with('profileImage')->getDictionary();
}
return View::make('conversations_page')
->with('users', $users)
->with('user', $currentUser)
->with('convs', $convs);
}