完成简约蓝官网皮肤

This commit is contained in:
augushong
2020-04-19 17:27:12 +08:00
parent 9910dd3e6d
commit 1d93be3280
14 changed files with 524 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace app\model;
use think\facade\Config;
use think\Model;
/**
@@ -64,4 +65,40 @@ class Category extends Model
return $list_post;
}
public function getTplNameAttr($value)
{
return Config::get('view_type.category.'.$value);
}
public function getModelParentAttr()
{
$pid = $this->getData('pid');
if($pid == 0){
return $this;
}
return Category::where('id',$pid)->find();
}
// 返回除自身以外的其他的同级同类的分类
public function getModelSiblingsAttr()
{
return Category::where('pid',$this->getData('pid'))
->where('level',$this->getData('level'))
->where('id','<>',$this->getData('id'))
->select();
}
/**
* 获取同一个父元素的分类,包含自身
*
* @return void
*/
public function getModelSameParentAttr()
{
return Category::where('pid',$this->getData('pid'))
->where('level',$this->getData('level'))
->select();
}
}

View File

@@ -33,6 +33,18 @@ class Post extends Model
return $this->hasMany(PostTag::class,'post_id');
}
public function setPublishTimeAttr($value)
{
return strtotime($value);
}
public function getPublishTimeTextAttr()
{
$value = $this->getData('publish_time');
return date('Y-m-d',$value);
}
public function getCategorysListAttr()
{
$list_post_categorys = $this->getAttr('categorys');
@@ -50,8 +62,6 @@ class Post extends Model
$list = array_column($list_post_tags->append(['tag'])->toArray(),'tag');
$list = array2level($list);
return $list;
}
@@ -66,6 +76,29 @@ class Post extends Model
return $desc;
}
public function getDescListAttr()
{
$desc = $this->getData('desc');
if(empty($desc)){
return '';
}
$list = explode("\n", $desc);
return $list;
}
public function getDescHtmlAttr()
{
$desc = $this->getData('desc');
if(empty($desc)){
return '';
}
return str_replace("\n",'<br>',$desc);
}
public function getStatusNameAttr()
{
return self::$stausNameList[$this->getData('status')];