duplicate logs
miladbrave opened this issue · 5 comments
How can duplicate logs be prevented? For example if a person refresh several time in a page system add new log so it causes misinformation!!
please add this feature to the package and send a pull request. I will merge it.
Good morning dear friend,
I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !
Good morning dear friend,
I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !
Bonjour cher ami,
Je constate qu'il y a des doublons. Avez-vous pu corriger ce bug? Si oui, dites-nous comment procéder pour corriger le lien. Merci!
Good morning dear friend,
I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !
wtf, I tried writing code in visitor but it doesn't affect it at all, it can still duplicate logs
example in file Visitor.php :
public function visit(Model $model = null)
{
if (in_array($this->request->path(), $this->except)) {
return;
}
$data = $this->prepareLog();
// Check for existing log to prevent duplicates
$existingVisit = Visit::where('ip', $data['ip'])
->where('url', $data['url'])
->where('device', $data['device'])
->where('platform', $data['platform'])
->first();
if ($existingVisit) {
return $existingVisit;
}
if (null !== $model && method_exists($model, 'visitLogs')) {
$visit = $model->visitLogs()->create($data);
} else {
$visit = Visit::create($data);
}
return $visit;
}
why ?
If you want no duplication, I have tried using if logic, and bringing in a model or you can use a query builder
example code in file home your website :
$visit = ViewPage::where('ip', $request->ip())->count(); // Check for existing log to prevent duplicates
if ($visit >= 1) {
return view(getTheme('home'));
}else{
visitor()->visit(); // create a visit log
return view(getTheme('home'));
}
I think editing the file in /shetabit/src/Visitor.php
You can change the log to not duplicate it, but it's still the code example that I showed above