增加访问分析缓存

This commit is contained in:
2023-07-08 09:22:29 +08:00
parent f534c7c473
commit 944000ecce
6 changed files with 78 additions and 4 deletions

View File

@@ -14,6 +14,11 @@ class PostVisit extends Model
{
//
protected $json = [
'client_os',
'client',
];
public function post()
{
return $this->belongsTo(Post::class, 'post_id');
@@ -55,4 +60,21 @@ class PostVisit extends Model
return show_time_ago($value);
}
public function getClientNameAttr()
{
$client = $this->getAttr('client');
return $client->name ?? '';
}
public function getClientOsNameAttr()
{
$client_os = $this->getAttr('client_os');
$name = $client_os->name ?? '';
$version = $client_os->version ?? '';
return "$name $version";
}
}