我注意到,如果您单击后端中的头像,则可以添加标题说明,但是当我这样做时,它既不保存,也没有浏览文档,但是找不到方法来保存此信息以及如何保存该信息。访问此信息,对于上传到后端的文件,您具有相同的行为,如果可能,我想利用此功能。这就是回声了
{
"id": 23,
"disk_name": "5f29c6cd94e57384113678.pdf",
"file_name": "instructions_for_use.pdf",
"file_size": 388398,
"content_type": "application/pdf",
"title": null,
"description": null,
"field": "pdf",
"sort_order": 23,
"created_at": "2020-08-04 20:36:29",
"updated_at": "2020-08-04 20:36:32",
"path": "http://test.test/storage/app/uploads/public/5f2/9c6/cd9/5f29c6cd94e57384113678.pdf",
"extension": "pdf"
}
说明,但找不到用于存储标题字段的方法
答案 0 :(得分:0)
将标题和说明添加到头像,其工作原理,
其文件的标题和描述属性。
如果您使用的是attachments $attachOne $attachMany
,则也可以使用此属性。
这是常规属性,如果要设置它,可以轻松地直接设置它们
// if you have relation like this
public $attachOne = [
'avatar' => 'System\Models\File'
];
// create file instance
$file = new System\Models\File;
$file->data = Input::file('file_input');
$file->is_public = true;
// you can directly set them
$file->title = 'some title';
$file->description = 'some description';
$file->save();
// your $model using avatar relation
$model->avatar = $file;
$model->save();
// now you can use it directly
$echo $model->avatar->title; // -> some title
查看更多参考 文件 https://github.com/octobercms/october/blob/master/modules/system/models/File.php
Github表架构
system_files
https://github.com/octobercms/october/blob/master/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php
如有疑问,请发表评论。