bubasuma\simplechat\db\Conversation::unread PHP Method

unread() public static method

public static unread ( $userId, $contactId ) : array
$userId
$contactId
return array
    public static function unread($userId, $contactId)
    {
        /** @var Message $message */
        $message = Message::find()->where(['sender_id' => $contactId, 'receiver_id' => $userId, 'is_deleted_by_receiver' => false])->orderBy(['id' => SORT_DESC])->limit(1)->one();
        $count = 0;
        if ($message) {
            $message->is_new = 1;
            $count = intval($message->update());
        }
        return compact('count');
    }