Skip to content

Commit

Permalink
Update read/unread notification relationships to build off base relat…
Browse files Browse the repository at this point in the history
…ionship. (#17093)
  • Loading branch information
patrickcarlohickman authored and taylorotwell committed Jan 3, 2017
1 parent b1a951b commit 16b3725
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Illuminate/Notifications/HasDatabaseNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ public function notifications()
*/
public function readNotifications()
{
return $this->morphMany(DatabaseNotification::class, 'notifiable')
->whereNotNull('read_at')
->orderBy('created_at', 'desc');
return $this->notifications()
->whereNotNull('read_at');
}

/**
* Get the entity's unread notifications.
*/
public function unreadNotifications()
{
return $this->morphMany(DatabaseNotification::class, 'notifiable')
->whereNull('read_at')
->orderBy('created_at', 'desc');
return $this->notifications()
->whereNull('read_at');
}
}

0 comments on commit 16b3725

Please sign in to comment.