显示文章状态

This commit is contained in:
2020-04-18 21:46:18 +08:00
parent e9b0e96a95
commit d35febf9f6
2 changed files with 12 additions and 0 deletions

View File

@@ -14,6 +14,11 @@ class Post extends Model
{
//
public static $stausNameList = [
0=>'不发布',
1=>'发布'
];
use SoftDelete;
protected $defaultSoftDelete = 0;
@@ -28,6 +33,11 @@ class Post extends Model
return $this->hasMany(PostTag::class,'post_id');
}
public function getStatusNameAttr()
{
return self::$stausNameList[$this->getData('status')];
}
public function setPubishTimeAttr($value)
{
return strtotime($value);

View File

@@ -44,6 +44,7 @@
<th>封面</th>
<th>简介</th>
<th>排序</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
@@ -57,6 +58,7 @@
<td><img src="{$vo.poster}" alt=""></td>
<td>{$vo.desc}</td>
<td>{$vo.sort}</td>
<td>{$vo.status_name}</td>
<td>
<div class="layui-btn-container">
<a class="layui-btn layui-btn-sm" href="{:url('edit',['id'=>$vo.id])}">编辑</a>