diff --git a/extend.php b/extend.php index 12e59d4..4889c01 100644 --- a/extend.php +++ b/extend.php @@ -41,7 +41,8 @@ })->relationship(DV_RELATIONSHIP_LATEST, function (AbstractModel $model) use ($settings) { return $model->views()->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5)); })->relationship(DV_RELATIONSHIP_UNIQUE, function (AbstractModel $model) use ($settings) { - return $model->views()->groupBy('user_id')->havingRaw('user_id IS NOT NULL')->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5)); + return $model->views()->groupBy('user_id')->havingRaw('user_id IS NOT NULL')->orderByRaw('MAX(visited_at) DESC') + ->limit($settings->get('michaelbelgium-discussionviews.max_listcount', 5)); }), (new Settings)