0

我注意到,如果您单击后端中的头像,您可以添加标题和描述,但是当我这样做时,它也不会保存我已经查看了文档,但找不到保存此信息的方法以及如何访问此信息,对于上传到后端的文件,您具有相同的行为,如果可能,我想利用此功能。这是呼应出来的

{
    "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"
}

描述但找不到存储标题字段的方法

4

1 回答 1

0

为头像添加标题和描述,它的工作,

其文件的标题和描述属性。

如果您正在使用attachments $attachOne $attachMany,您也可以使用此属性。

https://octobercms.com/docs/database/attachments

这是普通属性,如果你想设置它你可以很容易地直接设置它们

例如:


// 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

如有任何疑问,请发表评论。

于 2020-08-06T17:56:39.487 回答