i working for real-time notification .
notification send but not real-time i need to refresh page to enable receive
notification.vue
<script>
import NotificationItem from './NotificationItem.vue';
export default {
props: ['unreads', 'userid'],
components: {NotificationItem},
data(){
return {
unreadNotifications: this.unreads,
}
},
methods: {
markNotificationAsRead() {
if (this.unreadNotifications.length) {
axios.get('markAsRead');
}
}
},
mounted() {
console.log('Component mounted.');
Echo.private('App.User.' + this.userid)
.notification((notification) => {
console.log(asd);
let newUnreadNotifications = {data: {thread: notification.thread, user: notification.user}};
this.unreadNotifications.push(newUnreadNotifications);
});
}
}
</script>
<template>
<li class="dropdown" @click="markNotificationAsRead">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="glyphicon glyphicon-globe"></span> Notifications <span
class="badge alert-danger"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<notification-item :key="unread.id" v-for="unread in unreadNotifications" :unread="unread"></notification-item>
</li>
</ul>
</li>
</template>
script execute all but the following code not work
Echo.private('App.User.' + this.userid)
.notification((notification) => {
console.log(asd);
let newUnreadNotifications = {data: {thread: notification.thread, user: notification.user}};
this.unreadNotifications.push(newUnreadNotifications);
});
anyone can help plz ? i searched alot but not found solution ??
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tGOM75
via IFTTT
Aucun commentaire:
Enregistrer un commentaire