jeudi 27 juillet 2017

Echo.private laravel 5.4 not work

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 ??



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire