pcrt/yii2-attachments

Yii2-select2附件管理实现

1.0.0 2021-11-02 09:09 UTC

This package is auto-updated.

Last update: 2024-09-16 17:58:03 UTC


README

配置

安装后,需要连接迁移,在config/console.php中插入以下代码

'aliases' => [
    '@pcrt/file' => '@vendor/pcrt/yii2-attachments'
],

'controllerMap' => [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationNamespaces' => [
            'pcrt\file\migrations'
        ]   
    ]
]

然后,使用php yii migrate执行迁移。

之后,在config/web.php中设置配置

'modules' => [
    'attachments' => [
        'class' => 'pcrt\file\Module',
        'filePluginSavePath' => '/files' //cartella del filesystem in cui salvare i file (all'interno della directory pubblica di yii)
    ]
]

示例小部件

FileUploader::widget([
    'model_classname' => 'Attachment', //nome dell'entità o tabella
    'model_id' => 1, //id dell'elemento
])