diff --git a/classes/RedirectManager.php b/classes/RedirectManager.php index 5dfc415..92a6ce1 100644 --- a/classes/RedirectManager.php +++ b/classes/RedirectManager.php @@ -622,6 +622,11 @@ private function addLogEntry(RedirectRule $rule, string $requestUri, string $toU try { $fromToHash = sha1($requestUri . $toUrl); + $record = Models\RedirectLog::query() + ->where('redirect_id', $rule->getId()) + ->where('from_to_hash', $fromToHash) + ->first(); + Models\RedirectLog::query()->updateOrCreate([ 'redirect_id' => $rule->getId(), 'from_to_hash' => $fromToHash, @@ -631,7 +636,7 @@ private function addLogEntry(RedirectRule $rule, string $requestUri, string $toU 'from_url' => $requestUri, 'to_url' => $toUrl, 'status_code' => $rule->getStatusCode(), - 'hits' => DB::raw('hits + 1'), + 'hits' => ($record ? ($record->hits + 1) : 1), 'updated_at' => date('Y-m-d H:i:s'), ]); } catch (Throwable) {