mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
完成文案分享
This commit is contained in:
@@ -16,8 +16,8 @@ class Post extends Model
|
||||
//
|
||||
|
||||
public static $stausNameList = [
|
||||
0=>'不发布',
|
||||
1=>'发布'
|
||||
0 => '不发布',
|
||||
1 => '发布'
|
||||
];
|
||||
|
||||
use SoftDelete;
|
||||
@@ -26,12 +26,12 @@ class Post extends Model
|
||||
|
||||
public function categorys()
|
||||
{
|
||||
return $this->hasMany(PostCategory::class,'post_id');
|
||||
return $this->hasMany(PostCategory::class, 'post_id');
|
||||
}
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany(PostTag::class,'post_id');
|
||||
return $this->hasMany(PostTag::class, 'post_id');
|
||||
}
|
||||
|
||||
public function setPublishTimeAttr($value)
|
||||
@@ -42,22 +42,22 @@ class Post extends Model
|
||||
{
|
||||
|
||||
$value = $this->getData('publish_time');
|
||||
return date('Y-m-d',$value);
|
||||
return date('Y-m-d', $value);
|
||||
}
|
||||
public function getPublishTimeDatetimeAttr()
|
||||
{
|
||||
|
||||
$value = $this->getData('publish_time');
|
||||
return date('Y-m-d H:i:s',$value);
|
||||
return date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
public function getCategorysListAttr()
|
||||
{
|
||||
$list_post_categorys = $this->getAttr('categorys');
|
||||
|
||||
$list = array_column($list_post_categorys->append(['category'])->toArray(),'category');
|
||||
$list = array_column($list_post_categorys->append(['category'])->toArray(), 'category');
|
||||
|
||||
$list = array2level($list,0,0);
|
||||
$list = array2level($list, 0, 0);
|
||||
|
||||
return $list;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class Post extends Model
|
||||
{
|
||||
$list_post_tags = $this->getAttr('tags');
|
||||
|
||||
$list = array_column($list_post_tags->append(['tag'])->toArray(),'tag');
|
||||
$list = array_column($list_post_tags->append(['tag'])->toArray(), 'tag');
|
||||
|
||||
return $list;
|
||||
}
|
||||
@@ -75,8 +75,8 @@ class Post extends Model
|
||||
{
|
||||
$desc = $this->getData('desc');
|
||||
|
||||
if(strlen($desc) > 100){
|
||||
$desc = mb_substr($desc,0,100).'...';
|
||||
if (strlen($desc) > 100) {
|
||||
$desc = mb_substr($desc, 0, 100) . '...';
|
||||
}
|
||||
|
||||
return $desc;
|
||||
@@ -86,7 +86,7 @@ class Post extends Model
|
||||
{
|
||||
$desc = $this->getData('desc');
|
||||
|
||||
if(empty($desc)){
|
||||
if (empty($desc)) {
|
||||
return '';
|
||||
}
|
||||
$list = explode("\n", $desc);
|
||||
@@ -98,11 +98,11 @@ class Post extends Model
|
||||
{
|
||||
$desc = $this->getData('desc');
|
||||
|
||||
if(empty($desc)){
|
||||
if (empty($desc)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return str_replace("\n",'<br>',$desc);
|
||||
return str_replace("\n", '<br>', $desc);
|
||||
}
|
||||
|
||||
public function getStatusNameAttr()
|
||||
@@ -126,12 +126,12 @@ class Post extends Model
|
||||
|
||||
public function getContentAttr($value)
|
||||
{
|
||||
return json_decode($value,true);
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
public function getPosterAttr($value)
|
||||
{
|
||||
if(empty($value)){
|
||||
if (empty($value)) {
|
||||
$value = '/static/images/avatar.jpeg';
|
||||
}
|
||||
|
||||
@@ -142,7 +142,17 @@ class Post extends Model
|
||||
{
|
||||
$url_info = parse_url((string)url('index/Index/index')->domain('www'));
|
||||
|
||||
return $url_info['scheme'].'://'.$url_info['host'].'/a'.$this->getData('uid').'.html';
|
||||
return $url_info['scheme'] . '://' . $url_info['host'] . '/a' . $this->getData('uid') . '.html';
|
||||
}
|
||||
|
||||
public function getShareTextAttr()
|
||||
{
|
||||
$shareText = get_system_config('post_share_text_tpl');
|
||||
|
||||
$shareText = str_replace('%post_title%',$this->getAttr('title'),$shareText);
|
||||
$shareText = str_replace('%post_desc%',$this->getAttr('desc'),$shareText);
|
||||
$shareText = str_replace('%post_url%',$this->getAttr('read_url'),$shareText);
|
||||
|
||||
return $shareText;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user