mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
54 lines
934 B
PHP
54 lines
934 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\model;
|
|
|
|
use think\facade\Request;
|
|
use think\Model;
|
|
|
|
/**
|
|
* @mixin \think\Model
|
|
*/
|
|
class PostVisit extends Model
|
|
{
|
|
//
|
|
|
|
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);
|
|
}
|
|
}
|