2020-11-05 17:40:51 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare (strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Model\Article;
|
|
|
|
|
|
|
|
use App\Model\BaseModel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 笔记数据表模型
|
|
|
|
*
|
2021-04-22 16:14:34 +08:00
|
|
|
* @property integer $id 笔记ID
|
|
|
|
* @property integer $user_id 用户ID
|
|
|
|
* @property integer $class_id 分类ID
|
|
|
|
* @property string $tags_id 笔记标签ID
|
|
|
|
* @property string $title 笔记标题
|
|
|
|
* @property string $abstract 笔记摘要
|
|
|
|
* @property string $image 笔记头图
|
|
|
|
* @property integer $is_asterisk 是否标记星号
|
|
|
|
* @property integer $status 笔记状态
|
|
|
|
* @property string $created_at 创建时间
|
|
|
|
* @property string $updated_at 更新时间
|
|
|
|
* @property string $deleted_at 删除时间
|
2020-11-05 17:40:51 +08:00
|
|
|
* @package App\Model\Article
|
|
|
|
*/
|
|
|
|
class Article extends BaseModel
|
|
|
|
{
|
|
|
|
protected $table = 'article';
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'user_id',
|
|
|
|
'class_id',
|
2022-01-17 21:06:27 +08:00
|
|
|
'tags_id',
|
2020-11-05 17:40:51 +08:00
|
|
|
'title',
|
|
|
|
'abstract',
|
|
|
|
'image',
|
|
|
|
'is_asterisk',
|
|
|
|
'status',
|
|
|
|
'created_at',
|
|
|
|
'updated_at',
|
2022-01-17 21:06:27 +08:00
|
|
|
'deleted_at',
|
2020-11-05 17:40:51 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
protected $casts = [
|
2021-04-20 16:30:57 +08:00
|
|
|
'user_id' => 'integer',
|
|
|
|
'class_id' => 'integer',
|
2020-11-05 17:40:51 +08:00
|
|
|
'is_asterisk' => 'integer',
|
2021-04-20 16:30:57 +08:00
|
|
|
'status' => 'integer',
|
|
|
|
'created_at' => 'datetime',
|
|
|
|
'updated_at' => 'datetime'
|
2020-11-05 17:40:51 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关联笔记详细表(一对一关系)
|
|
|
|
*
|
|
|
|
* @return \Hyperf\Database\Model\Relations\HasOne
|
|
|
|
*/
|
|
|
|
public function detail()
|
|
|
|
{
|
|
|
|
return $this->hasOne(ArticleDetail::class, 'article_id', 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关联笔记附件信息表(一对多关系)
|
|
|
|
*
|
|
|
|
* @return \Hyperf\Database\Model\Relations\HasMany
|
|
|
|
*/
|
|
|
|
public function annexs()
|
|
|
|
{
|
|
|
|
return $this->hasMany(ArticleAnnex::class, 'article_id', 'id');
|
|
|
|
}
|
|
|
|
}
|