Laravel Talk — A realtime messaging system

Talk is a Laravel based realtime messaging or conversation system. You can easily integrate this package with any Laravel based project. It helps you to develop a messaging system in just few mins.

Features

  • Head to head messaging
  • Realtime messaging
  • Creating new conversation
  • Message threads with latest one
  • View conversations by user id or conversation id
  • Support pagination in threads and messages
  • Delete(soft delete) message from both end. Sender and receiver can delete their message from their end.
  • Permanent delete message
  • Mark message as seen
  • Only participant can view or access there own message or message threads

Installations

You can install Talk via composer. Run this command from your terminal.

composer require nahid/talk

Configurations

When the download is complete, you have to call this package service in config/app.php config file. To do that, add this line in app.php in providers section

Nahid\Talk\TalkServiceProvider::class,

To use facade you have to add this line in app.php in aliases array

'Talk'      => Nahid\Talk\Facades\Talk::class,

Now run this command in your terminal to publish this package resources

php artisan vendor:publish --provider="Nahid\Talk\TalkServiceProvider"

After running this command, all necessary file will be included in your project. This package has two default migrations. So you have to run migrate command like this. (But make sure your database configuration is configured correctly.)

php artisan migrate

Okay, now you need to configure your user model for Talk. Go to config/talk.php and config it.

return [
'user' => [
'model' => 'App\User'
],
'broadcast' => [
'enable' => false,
'app_name' => 'your-app-name',
'pusher' => [
'app_id' => '',
'app_key' => '',
'app_secret' => '',
'options' => [
'cluster' => 'ap1',
'encrypted' => true
]
]
]
];

Usage

Its very easy to use. If you want to set authenticate user id globally then you have to set a middleware first. Go to app/Http/Kernel.php and set it in $routeMiddleware array

'talk'  =>  \Nahid\Talk\Middleware\TalkMiddleware::class,

And now you can use it from anywhere with middleware. Suppose you have a Controller and you want to set authenticate user id globally then write this in controller constructor

$this->middleware('talk');

But instead of set id globally you can use these procedure from any method in controller.

Talk::setAuthUserId(auth()->user()->id);

Now you may use any method what you need. But if want pass authentic id instantly, this method may help you.

Talk::user(auth()->user()->id)->anyMethodHere();

To see full API documentation you can visit this link.

If you confused how to work with Talk? Don’t worry, here is a sample project Talk-Example for you.

You can feel free to Give us your feedback and suggestions.

Thank you :)