'boolean', 'clicked_at' => 'datetime', ]; public function shortLink(): BelongsTo { return $this->belongsTo(ShortLink::class); } public function contextLabel(): string { $parts = array_filter([ $this->device_type ? ucfirst($this->device_type) : null, $this->browser, $this->os, $this->country ? LinkGeoResolver::countryLabel($this->country) : null, ]); $context = $parts !== [] ? implode(' · ', $parts) : null; $referer = $this->referer ? parse_url($this->referer, PHP_URL_HOST) ?: $this->referer : 'Direct'; return $context ? "{$context} · via {$referer}" : "via {$referer}"; } }