【发布时间】:2017-03-03 14:51:56
【问题描述】:
我是 OctoberCMS 的新手,我正在尝试使用 builder 插件 本身创建一个插件,OctoberCMS 提供 OctoberCMS Builder Plugin 类似“社交链接”,一切正常,但我无法理解将文件上传到任何目录并将该名称存储到我的数据库表的特定字段的逻辑。我的表的字段名称是“social_logo”,我试图在其中存储将要上传的文件名。
我现在可以将文件上传到默认目录,无论哪个OctoberCMS与我上传的文件一起生成。但问题是我无法将该特定文件名存储到我的数据库表的字段中。
有人可以指导我该怎么做才能实现这一目标吗?
这是我到目前为止所做的模型文件。
SocialLinks.php
<?php namespace Technobrave\SocialLinks\Models;
use Model;
/**
* Model
*/
class Sociallink extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Validation
*/
public $rules = [
];
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'technobrave_sociallinks_';
public $attachOne = [
'social_logo' => 'System\Models\File'
];
}
Fields.yaml
fields:
social_logo:
label: 'technobrave.sociallinks::lang.Sociallink.social_logo'
span: auto
oc.commentPosition: ''
mode: file
useCaption: true
thumbOptions:
mode: crop
extension: auto
type: fileupload
columns.yaml
columns:
social_logo:
label: 'technobrave.sociallinks::lang.Sociallink.social_logo'
type: text
searchable: true
sortable: true
正如您在上面的代码中看到的,现在我只有 1 个字段,因为我仅在上传图像时遇到此特定字段的问题,我想存储该文件名。所有其他对我有用的表单属性,如文本、文本区域等,所以现在我只是想用这个单一的字段来实现这个目标。
有人可以指导我该怎么做才能解决这个问题吗?
谢谢
【问题讨论】:
标签: octobercms