Notebook
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

59 lines
1.7 KiB

<?php
namespace Plugins\Notebook\Model;
use App\Model\Attribute\CreateSql;
use App\Model\Model;
/**
* 笔记协作人员
* @property int $id ID
* @property int $notebook_id 笔记
* @property int $administrators_id 管理员
* @property int $mode 权限
* @property string $create_time
* @property string $update_time
* @property int $delete_time
* @property Notebook $notebook
*/
#[CreateSql(<<<SQL
CREATE TABLE `sd_notebook_user` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'ID',
`notebook_id` int NOT NULL DEFAULT '0' COMMENT '笔记',
`administrators_id` int NOT NULL DEFAULT '0' COMMENT '管理员',
`mode` tinyint(1) NOT NULL DEFAULT '1' COMMENT '权限:1=只读,2=读写',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:1=正常,2=提出',
`create_time` datetime NOT NULL,
`update_time` datetime NOT NULL,
`delete_time` int DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='笔记协作人员'
SQL)]
class NotebookUser extends Model
{
protected ?string $table = 'notebook_user';
protected array $casts = [
...self::DEFAULT_CASTS,
// 更多casts
];
protected array $fillable = ["notebook_id", "administrators_id", "mode", "status"];
public function setNotebookIdAttribute($value): int
{
return $this->attributes['notebook_id'] = (int)$value;
}
public function setAdministratorsIdAttribute($value): int
{
return $this->attributes['administrators_id'] = (int)$value;
}
public function notebook()
{
return $this->belongsTo(Notebook::class);
}
}