10 月 CMS 为 system_files 表指定attachment_type

问题描述 投票:0回答:1

对于system_files表中的attachment_type字段,会自动生成带有类名的字符串。如何设置指定类字符串?

现在看起来像这样:

public $attachOne = [
    'main_photo' => [
        'System\Models\File',
        'delete' => true,
    ]
];
laravel-5 octobercms octobercms-backend
1个回答
0
投票

我在这里假设,但我猜您不希望将完整的类存储在

attachment_type
表的
system_files
列中。

您可以做的是在插件的

boot()
文件的
Plugin.php
方法中定义变形贴图。

因此,如果您在

October\Shop
命名空间中有一个插件,并且具有
Product
模型,则可以执行此操作。

// Plugin.php

<?php

namespace October\Shop;

use System\Classes\PluginBase;
use October\Rain\Database\Relations\Relation;

class Plugin extends PluginBase
{
    public function boot()
    {
        Relation::morphMap([
            'product' => \October\Shop\Models\Product::class,
        ]);
    }

    /** The rest of your plugin.php file **/
}

您可以在文档中阅读相关内容。

OctoberCMS 第 2 版文档:自定义多态类型

OctoberCMS 版本 3 文档:自定义多态类型

© www.soinside.com 2019 - 2024. All rights reserved.