*/ protected $fillable = [ 'sop_template_id', 'version', 'change_log', 'content_snapshot', 'created_by', ]; /** * 属性类型转换 * * @return array */ protected function casts(): array { return [ 'content_snapshot' => 'array', 'created_at' => 'datetime', ]; } /** * 获取版本所属的模板 * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function template() { return $this->belongsTo(SopTemplate::class, 'sop_template_id'); } /** * 获取版本的创建者 * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function creator() { return $this->belongsTo(User::class, 'created_by'); } }