MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/www/amanda/app/ChatHistory.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class chatHistory extends Model
{
	protected  $table="chat_history";
    // use SoftDeletes;

    protected $fillable = [
        'from','to','message','fileName','read_status'
    ];

    public static function getUnredMessageCount($from,$to)
    {
        $result= ChatHistory::where(array("from"=>$from,"to"=>$to,"read_status"=>"unread"))->count();
        return $result;
    }

    /*public static function getLatestTimeStamp($from,$to)
    {*/
        // $parameter['from']=$from;
        // $parameter['to']=$to;

        /*$result = ChatHistory::
                    where(array("from"=>$from, "to"=>$to, "read_status"=>"unread"))->orwhere(array("from"=>$to, "to"=>$from, "read_status"=>"unread" ))->orderBy('created_at','desc')->first();*/

        //$result = ChatHistory::where('created_at', ChatHistory::max('created_at'))->orderBy('created_at','desc')->first();

       /* print_r($result['created_at'];);
        die();*/
      /*  where(function($query) use ($parameter)
      {
          $query->where('chat_history.from', '=', $parameter['from'])
                ->where('chat_history.to', '=', $parameter['to']);
      })  
     ->orwhere(function($query) use ($parameter)
      {
          $query->where('chat_history.from', '=', $parameter['to'])
                ->where('chat_history.to', '=', $parameter['from']);
      })  */
                /*->orderBy('id','desc')->first();*/
        /*return $result['created_at'];
    }*/

    public static function updateUnredMessage($from,$to)
    {
        $result= ChatHistory::
        where(array("from"=>$from,"to"=>$to,"read_status"=>"unread"))
        ->update(array("read_status"=>"read"));
        return $result;
    }

}