File tree 2 files changed +20
-15
lines changed
2 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -110,20 +110,25 @@ protected function shouldBeLoggedAgain(Visit $visit): bool
110
110
111
111
public function __destruct ()
112
112
{
113
- if (! $ this ->isCrawler ) {
114
- $ visit = $ this ->model
115
- ->visits ()
116
- ->latest ()
117
- ->firstOrCreate ($ this ->buildJsonColumns (), [
118
- 'data ' => $ this ->attributes ,
119
- ]);
120
-
121
- $ visit ->when (
122
- $ this ->shouldBeLoggedAgain ($ visit ),
123
- function () use ($ visit ) {
124
- $ visit ->replicate ()->save ();
125
- }
126
- );
113
+ // if the current request is a crawler,
114
+ // we don't need to log the visit
115
+ // because it's not a real visitor
116
+ if ($ this ->isCrawler ) {
117
+ return null ;
127
118
}
119
+
120
+ $ visit = $ this ->model
121
+ ->visits ()
122
+ ->latest ()
123
+ ->firstOrCreate ($ this ->buildJsonColumns (), [
124
+ 'data ' => $ this ->attributes ,
125
+ ]);
126
+
127
+ $ visit ->when (
128
+ $ this ->shouldBeLoggedAgain ($ visit ),
129
+ function () use ($ visit ) {
130
+ $ visit ->replicate ()->save ();
131
+ }
132
+ );
128
133
}
129
134
}
Original file line number Diff line number Diff line change 225
225
request ()->headers ->set ('User-Agent ' , 'Googlebot ' );
226
226
$ post ->visit ();
227
227
228
- expect ($ post ->visits ->first ())->toBe (null );
228
+ expect ($ post ->visits ->count ())->toBe (0 );
229
229
});
You can’t perform that action at this time.
0 commit comments