完成简约蓝官网皮肤

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();
}
}