如何为October CMS的system_files表指定自定义attachment_type类字符串?
在October CMS中指定system_files表的attachment_type类字符串
默认配置下,attachOne关联会自动将当前模型的完整类名写入system_files表的attachment_type字段。如果需要自定义这个字段的类字符串,只需在关联配置中添加model参数,指定你想要的字符串即可:
public $attachOne = [ 'main_photo' => [ 'System\Models\File', 'delete' => true, 'model' => 'Your\Custom\ClassName' // 填写你指定的类字符串 ] ];
添加model参数后,attachment_type字段就会存储你设置的自定义字符串,替代原本自动生成的模型类名。
内容的提问来源于stack exchange,提问作者Юрий Жулин
相关产品推荐
相关产品推荐

