feat: Implement real-time chat with Reverb

This commit is contained in:
Daan Meijer
2026-06-15 00:44:55 +02:00
parent f8ee8165ff
commit 9cb87b61ef
13 changed files with 1267 additions and 5 deletions
+11
View File
@@ -1,6 +1,8 @@
<script setup>
import { useForm } from '@inertiajs/vue3';
import { route } from 'ziggy-js';
import { onMounted } from 'vue';
import { useEcho } from '@laravel/echo-vue';
const props = defineProps({
chat: Object,
@@ -10,6 +12,15 @@ const form = useForm({
content: '',
});
const echo = useEcho();
onMounted(() => {
echo.private(`chats.${props.chat.id}`)
.listen('MessageSent', (e) => {
props.chat.messages.push(e.message);
});
});
function submit() {
form.post(route('chats.messages.store', props.chat.id), {
onSuccess: () => form.reset(),