完成评论统计

This commit is contained in:
augushong
2021-01-03 22:02:34 +08:00
parent 3b5a56aef5
commit cc83df7fb9
5 changed files with 43 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\model;
use think\facade\Cache;
use think\Model;
use think\model\concern\SoftDelete;
use think\Paginator;
@@ -39,6 +40,15 @@ class Post extends Model
return $this->hasMany(PostComment::class,'post_id');
}
public function getCommentCountAttr()
{
return PostComment::getPostCommentsCount($this->getData('id'));
}
public function setPublishTimeAttr($value)
{
return strtotime($value);