mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
完成评论
This commit is contained in:
@@ -34,6 +34,11 @@ class Post extends Model
|
||||
return $this->hasMany(PostTag::class, 'post_id');
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(PostComment::class,'post_id');
|
||||
}
|
||||
|
||||
public function setPublishTimeAttr($value)
|
||||
{
|
||||
return strtotime($value);
|
||||
@@ -149,9 +154,9 @@ class Post extends Model
|
||||
{
|
||||
$share_text = get_system_config('post_share_text_tpl');
|
||||
|
||||
$share_text = str_replace('%post_title%',$this->getAttr('title'),$share_text);
|
||||
$share_text = str_replace('%post_desc%',$this->getAttr('desc'),$share_text);
|
||||
$share_text = str_replace('%post_url%',$this->getAttr('read_url'),$share_text);
|
||||
$share_text = str_replace('%post_title%', $this->getAttr('title'), $share_text);
|
||||
$share_text = str_replace('%post_desc%', $this->getAttr('desc'), $share_text);
|
||||
$share_text = str_replace('%post_url%', $this->getAttr('read_url'), $share_text);
|
||||
|
||||
return $share_text;
|
||||
}
|
||||
|
||||
35
app/model/PostComment.php
Normal file
35
app/model/PostComment.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\model;
|
||||
|
||||
use app\index\controller\Common;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class PostComment extends Model
|
||||
{
|
||||
//
|
||||
|
||||
public function post()
|
||||
{
|
||||
return $this->belongsTo(Post::class, 'post_id');
|
||||
}
|
||||
|
||||
public function getUserAttr()
|
||||
{
|
||||
return Common::getUserInfo($this->getData('user_uid'));
|
||||
}
|
||||
|
||||
public function getReadUrlAttr()
|
||||
{
|
||||
$model_post = $this->getAttr('post');
|
||||
|
||||
$read_url = $model_post->read_url . '#comment-' . $this->getData('id');
|
||||
|
||||
return $read_url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user