From 7fdac1b3f344a2a1691eac59adfe2a0a691bd4e4 Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Fri, 11 Sep 2020 19:15:15 +0200 Subject: [PATCH] distinct view count --- app/PdfFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PdfFile.php b/app/PdfFile.php index 5af133e..37938c6 100644 --- a/app/PdfFile.php +++ b/app/PdfFile.php @@ -49,7 +49,7 @@ use Vaites\ApacheTika\Client as TikaClient; * @property string $title * @property bool $is_free * @property Collection $accessLogs - * @property-read int $accessCount + * @property-read int $viewCount * */ class PdfFile extends TwillModel implements Sortable @@ -213,7 +213,7 @@ class PdfFile extends TwillModel implements Sortable */ public function getViewCountAttribute() { - return $this->accessLogs()->count(); + return $this->accessLogs()->distinct('user_id')->count(); } -- 2.39.5