From e106fa16cf7eb0b664704a227bfdbdd6f9c3ddd9 Mon Sep 17 00:00:00 2001 From: Melek REBAI Date: Sat, 29 Oct 2016 09:09:28 +0100 Subject: [PATCH] Add database notification relation readNotifications() --- .../Notifications/HasDatabaseNotifications.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Illuminate/Notifications/HasDatabaseNotifications.php b/src/Illuminate/Notifications/HasDatabaseNotifications.php index 807ebadc5005..c650bb8750b6 100644 --- a/src/Illuminate/Notifications/HasDatabaseNotifications.php +++ b/src/Illuminate/Notifications/HasDatabaseNotifications.php @@ -22,4 +22,14 @@ public function unreadNotifications() ->whereNull('read_at') ->orderBy('created_at', 'desc'); } + + /** + * Get the entity's read notifications. + */ + public function readNotifications() + { + return $this->morphMany(DatabaseNotification::class, 'notifiable') + ->whereNotNull('read_at') + ->orderBy('created_at', 'desc'); + } }