2017 © Pedro Peláez
 

library ping

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework.

image

harshaaliaschinna/ping

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework.

  • Monday, July 31, 2017
  • by harshaaliaschinna
  • Repository
  • 4 Watchers
  • 5 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 16 % Grown

The README.md

Laravel Messaging or Chat or Conversation Package (Ping)

Ping Logo, (*1)

Introduction

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework. It is easy to integrate and use., (*2)

Features

  • One to One Conversation.
  • Send a message without checking for conversation.
  • Check if user has access to a conversation.
  • Conversation's unread messages count (total & by user).
  • Retriving messages with auto marking as seen.
  • Marking all unread messages as seen (total & by user).
  • Deleting messages from the participant side.
  • Hard deletion (delete permanently) of messages and conversation.
  • Message Encryption (Coming soon!).
  • Group Conversation (Coming soon!).

Installation

To get started with Ping, use Composer to add the package to your project:, (*3)

composer require harshaaliaschinna/ping

Configuration

After installing the Ping package, register the Harshaaliaschinna\Ping\PingServiceProvider in your config/app.php configuration file:, (*4)

'providers' => [
    // Other service providers...

    Harshaaliaschinna\Ping\PingServiceProvider::class,
],

You don't need to add the Ping to alias array. We already done that for you :blue_heart:., (*5)

Migration

Run below command in your terminal to publish required migration files for this package., (*6)

php artisan vendor:publish --provider="Harshaaliaschinna\Ping\PingServiceProvider"

Finally run below command to execute migrations., (*7)

php artisan migrate

Basic Usage

Example 1:, (*8)

// Ping::setId(from_id)->send(to_id, message);
Ping::setId(1)->send(2, "Hello, How are you?");

Example 2:, (*9)

Ping::setId(1);
Ping::send(2, "Hello, How are you?");

Example 3:, (*10)

namespace App\Controllers;

..
use Ping;

class Demo extends Controller {
    public function __construct() {
        // Ping once initialized it can be used anywhere without setting From Id.
        Ping::setId(Auth::Id());
    }

    public function sendMessage($toId, $message) {
        ..
        ..
        Ping::send($toId, $message);
        ..
    }

    public function retriveMessage($Id) {
        ..
        $markAsSeen = true; // Bool
        $message = Ping::recieve($Id, $markAsSeen);
        ..
    }
    ..
    ..
    ..
}

API Reference

Method V0.1
setId() :heavy_check_mark:
send() :heavy_check_mark:
new() :heavy_check_mark:
exists() :heavy_check_mark:
receive() :heavy_check_mark:
receiveAll() :heavy_check_mark:
totalConnections() :heavy_check_mark:
unreadCount() :heavy_check_mark:
markAsSeen() :heavy_check_mark:
markUnreadAsSeen() :heavy_check_mark:
hasAccess() :heavy_check_mark:
delete() :heavy_check_mark:
hardDelete() :heavy_check_mark:
hardDeleteAll() :heavy_check_mark:
hardDeleteConnection() :heavy_check_mark:
hardDeleteConnectionByUserId() :heavy_check_mark:

****Note:*** Please note that connection and conversation both are same. As the package name itself refers to a Networking scenario, these words were used just for fun! :stuck_out_tongue: ., (*11)

setId

This method sets the base Id known as base_user. From which the requests can be made., (*12)

object setId( int $id )

Parameters:
Id: Unique Id from which further requests can be performed., (*13)

Return Values:
Returns Ping object. FALSE on errors., (*14)

send

Sends the message to other user. This method creates automatically a new connection if there is no connection between users. If there exists a connection already it will use it to send message., (*15)

object send( int $to_id, string $message)

Parameters:
to_id: Unique Id to which the message to be sent.
message: The message field., (*16)

Return Values:
Returns object on Success. FALSE on errors.
object returned containes newly sent message id ->id. It also containes connection id ->connection_id and few others., (*17)

new

Creates new connection between users., (*18)

object new( int $user_one[, int $user_two = null])

Parameters:
user_one: Unique Id.
user_two: If this field is not set, Ping will create a connection between base_user(user set through setId() method) and user_one. Else it will create a connection between user_one and user_two., (*19)

Return Values:
Returns object on Success. FALSE on errors.
returned object containes Connection id ->id, (*20)

exists

Checks whether a connection exists between base_user and provided user., (*21)

bool exists( int $user_two)

Parameters:
user_two: Unique Id. This method is dependent on setId(), (*22)

Return Values:
Returns object on Success. FALSE on errors., (*23)

receive

Retrives a message using message_id., (*24)

object receive( int $message_id[, $seen = false])

Parameters:
message_id: Message id should be passed to retrive message.
seen: Mark this message as seen., (*25)

Return Values:
Returns object on Success. FALSE on errors or not found., (*26)

receiveAll

Retrives all messages that are present in a connection or conversation using connection_id, (*27)

object receiveAll( int $connection_id[[[[, bool $seen = false], string $order = 'ASC'], int $skip=null], int $take=null])

Parameters:
connection_id: Connection id.
seen: Mark unread messages as seen by base_user. Default it will be as false., (*28)

Value Result
true Mark as seen
false Ignore

order: Order by ascending order or descending order using messages timestamp., (*29)

Value Result
ASC Ascending order
DESC Descending order

skip: number of messages to skip.
take: number of messages to retrive., (*30)

Return Values:
Returns object on Success. FALSE on errors or not found., (*31)

totalConnections

Retrives all connections that are linked to base_user or provided user., (*32)

object totalConnections([int $user_id=null])

Parameters:
user_id: If user_id is passed, Ping will retrive all connections based on provided user_id. Else it will use base_user as user_id and retrives all connections., (*33)

Return Values:
Returns object on Success. FALSE on errors or not found., (*34)

unreadCount

Retrives unread messages count based on connection_id., (*35)

int unreadCount( int $connection_id[, int $user_id=null])

Parameters:
connection_id: If user_id is passed, Ping will retrive all unread messages count based on provided user_id. Else it will use base_user as user_id and retrives the count.
user_id: If user_id is passed, Ping will set it as base_user and retrives unread message count. Else it will use base_user as user_id and retrives it., (*36)

Return Values:
Returns integer on Success. FALSE on errors or not found., (*37)

markAsSeen

Mark a message as seen., (*38)

bool markAsSeen( int $message_id)

Parameters:
message_id: Message Id should be passed., (*39)

Return Values:
Returns true on Success. FALSE on errors or not found., (*40)

markUnreadAsSeen

Mark all unread messages as seen using connection_id. If user_id is passed it will mark that user specific received messages as seen. Else it will mark all messages as seen in that particular connection., (*41)

bool markUnreadAsSeen( int $conection_id[, int $user_id = null])

Parameters:
connection_id: Specific connection_id should be passed.
user_id: If user_id is passed it will mark that users received messages as seen., (*42)

Return Values:
Returns true on Success. FALSE on errors or not found., (*43)

hasAccess

Checks whether a user has access to specific connection or not., (*44)

bool hasAccess( int $connection_id[, int $user_id = null])

Parameters:
connection_id: Specific connection_id should be passed.
user_id: If user_id is passed, Ping will check whether the given user_id has access to connection or not. Else it will use base_user as user_id and checks for access., (*45)

Return Values:
Returns true if user has access. FALSE if they don't have access., (*46)

delete

To delete a message from one user side., (*47)

bool delete( int $message_id[, int $user_id=null])

Parameters:
message_id: Specific message_id should be passed.
user_id: If user_id is passed, Ping will remove message from that user side. Else it will use base_user as user_id and removes from that user side., (*48)

Return Values:
Returns true on Success. FALSE on errors or not found., (*49)

hardDelete

Message will be deleted permanently from database. Any user present in that connection cannot retrive this message again., (*50)

bool hardDelete( int $message_id)

Parameters:
message_id: Specific message_id should be passed., (*51)

Return Values:
Returns true on Success. FALSE on errors or not found., (*52)

hardDeleteAll

This will delete all the messages permanently in a connection. In other words it will reset that connection., (*53)

bool hardDeleteAll( int $connection_id)

Parameters:
connection_id: Specific connection_id should be passed., (*54)

Return Values:
Returns true on Success. FALSE on errors or not found., (*55)

hardDeleteConnection

This will delete a connection & messages present in it permanently., (*56)

bool hardDeleteConnection( int $connection_id)

Parameters:
connection_id: Specific connection_id should be passed., (*57)

Return Values:
Returns true on Success. FALSE on errors or not found., (*58)

hardDeleteConnectionByUserId

This is same as hardDeleteConnection() but this method will accept user_id as parameter. Connection & messages that exists between base_user and provider user_id will be deleted permanently., (*59)

bool hardDeleteConnectionByUserId( int $user_id)

Parameters:
user_id: Specific user_id should be passed., (*60)

Return Values:
Returns true on Success. FALSE on errors or not found., (*61)

The Versions

31/07 2017

dev-master

9999999-dev

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Harsha vardhan

laravel message messaging chat message-system

31/07 2017

v0.1-p1

0.1.0.0-patch1

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Harsha vardhan

laravel message messaging chat message-system

25/07 2017

v0.1

0.1.0.0

Ping provides a simple and easy Messaging or Chat or Conversation system to your Laravel Framework.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Harsha vardhan

laravel message messaging chat message-system