Laravel change Connection for Notifications table

前端 未结 3 1770
鱼传尺愫
鱼传尺愫 2021-01-13 19:39

I am implementing Laravel 5.3 Notifications at the moment which is working very nice.

At the moment I am using \'email\' as a notifications channel but I want to add

3条回答
  •  不要未来只要你来
    2021-01-13 20:23

    On Laravel 5.7 based on @Bernard answer

    User.php

    Notifiable.php

    HasDatabaseNotifications.php

    morphMany(MultiConnectionDatabaseNotification::class, 'notifiable')->orderBy('created_at', 'desc');
        }
    
        /**
         * Get the entity's read notifications.
         *
         * @return \Illuminate\Database\Query\Builder
         */
        public function readNotifications()
        {
            return $this->notifications()->whereNotNull('read_at');
        }
    
        /**
         * Get the entity's unread notifications.
         *
         * @return \Illuminate\Database\Query\Builder
         */
        public function unreadNotifications()
        {
            return $this->notifications()->whereNull('read_at');
        }
    }
    

    MultiConnectionDatabaseNotification.php

提交回复
热议问题