belongsTo(Post::class, 'post_id'); } public function getAvatarSrcAttr() { $value = $this->getAttr('avatar'); if (empty($value)) { $value = '/static/images/avatar.png'; } return $value; } public function getNicknameTitleAttr() { $value = $this->getAttr('nickname'); if (empty($value)) { $current_ip = Request::ip(); $ip = $this->getAttr('ip'); if ($current_ip == $ip) { $value = '您的IP:' . $ip; } else { $value = 'IP用户:' . $ip; } } return $value; } public function getCreateTimeTitleAttr() { $value = $this->getData('create_time'); 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"; } }