'datetime', ]; /** * Get the document that was accessed. */ public function document(): BelongsTo { return $this->belongsTo(Document::class); } /** * Requests whose user agent looks like a crawler rather than a person. * Kept as a query-time filter rather than a write-time one so the raw * record stays complete and the definition can be changed later. */ public function scopeExcludingBots($query) { foreach (['%bot%', '%crawl%', '%spider%', '%slurp%'] as $pattern) { $query->where(function ($q) use ($pattern) { $q->whereNull('user_agent') ->orWhere('user_agent', 'not ilike', $pattern); }); } return $query; } }