Reputation: 143
I noticed that if you click on the avatar in the backend you can add a title an description but when I do it does not save either I Have looked through the documents but can not find a method to save this information and how to access this information, you have the same behavior for files uploaded to the backend I would like to utilize this feature if possible. This is what is echoed out
{
"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"
}
description but can not find method to store the title field
Upvotes: 0
Views: 128
Reputation: 9693
adding title and description to avatar, Its working,
Its file's title and description attribute.
if you are using attachments $attachOne $attachMany
you can also use this attributes.
This are normal attributes if you want to set it you can easily set them directly
// 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
Check for more references Docs https://github.com/octobercms/october/blob/master/modules/system/models/File.php
Github table schema
system_files
https://github.com/octobercms/october/blob/master/modules/system/database/migrations/2013_10_01_000002_Db_System_Files.php
if any doubt please comment.
Upvotes: 0