public static function saveRecord($content, $sentTime, $isReply, $conversationId, $accountId) { $chatMessage = new ChatMessage(); $chatMessage->content = $content; $chatMessage->sentTime = $sentTime; $chatMessage->isReply = $isReply; $chatMessage->conversationId = $conversationId; $chatMessage->accountId = $accountId; if (!$chatMessage->save()) { LogUtil::error(['message' => 'save chatMessage failed', 'error' => $chatMessage->errors], 'helpdesk'); throw new ServerErrorHttpException('save chatConversation failed'); } //update the lastChatTime for chatConversation ChatConversation::setLastChatTime($sentTime, $conversationId); return $chatMessage; }