完成内容管理

This commit is contained in:
augushong
2020-04-18 16:01:27 +08:00
parent dc15576de8
commit 84c1a51b86
18 changed files with 1548 additions and 253 deletions

View File

@@ -17,4 +17,38 @@ class Post extends Model
use SoftDelete;
protected $defaultSoftDelete = 0;
public function categorys()
{
return $this->hasMany(PostCategory::class,'post_id');
}
public function tags()
{
return $this->hasMany(PostTag::class,'post_id');
}
public function setPubishTimeAttr($value)
{
return strtotime($value);
}
public function setContentAttr($value)
{
return json_encode($value);
}
public function getContentAttr($value)
{
return json_decode($value,true);
}
public function getPosterAttr($value)
{
if(empty($value)){
$value = '/static/images/avatar.jpeg';
}
return get_source_link($value);
}
}