hasOne(WebSocketDialog::class, 'id', 'dialog_id'); } /** * 更新对话最后消息时间 * @return WebSocketDialogMsg|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|object|null */ public static function updateMsgLastAt($dialogId) { $lastMsg = WebSocketDialogMsg::whereDialogId($dialogId)->orderByDesc('id')->first(); if ($lastMsg) { WebSocketDialogUser::whereDialogId($dialogId)->change(['last_at' => $lastMsg->created_at]); } return $lastMsg; } }