mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
完成简约蓝官网皮肤
This commit is contained in:
@@ -51,10 +51,10 @@ class Category extends Common
|
||||
//
|
||||
|
||||
$model_category = ModelCategory::with('posts.post')->find($id);
|
||||
|
||||
|
||||
$this->assign('category',$model_category);
|
||||
|
||||
return $this->fetch('read'.$model_category->tpl_name);
|
||||
return $this->fetch('read'.$model_category->getData('tpl_name'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
93
app/index/controller/Post.php
Normal file
93
app/index/controller/Post.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\index\controller;
|
||||
|
||||
use app\model\Post as ModelPost;
|
||||
use think\Request;
|
||||
|
||||
class Post extends Common
|
||||
{
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示创建资源表单页.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新建的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function save(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
|
||||
$model_post = ModelPost::find($id);
|
||||
|
||||
$this->assign('post', $model_post);
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存更新的资源
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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')];
|
||||
|
||||
Reference in New Issue
Block a user