Blog Detail

17

May
Add a real-time user message chat system with Laravel-Talk cover image

arrow_back Add a real-time user message chat system with Laravel-Talk

Talk is a Laravel-based user conversation (chatting) system with real-time messaging. You can easily integrate this package with any Laravel-based project. It helps you to develop a messaging system in just a few minutes. Here is a project screenshot that was developed by Talk. This package has many 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 message or message threads
  • Inline url render using oembed specifications

Installation

Talk is a Laravel package so you can install it via Composer. Run this command in your terminal from your project directory:

composer require nahid/talk

Wait for a while, Composer will automatically install Talk in your project.

Configuration

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 the 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#

Usage

It’s 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 the controller constructor:

$this->middleware('talk');

But instead of set id globally, you can use this procedure from any method in the controller:

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

Now you may use any method that you need. But if want to pass an authentic id instantly, this method may help you:

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

Please see the API Doc.

For more details, Visit Github.

Published at : 17-05-2022

Author : Rizwan Aslam
AUTHOR
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project