hanson/laravel-admin-qiniu

There is no license information available for the latest version (dev-master) of this package.

dev-master 2020-03-08 03:31 UTC

This package is auto-updated.

Last update: 2024-11-08 13:35:57 UTC


README

Laravel admin 框架的七牛 qiniu 多图上传扩展,可拖拽,异步上传图片,支持删除

1_7M_G0VFANP6HK48EEL2QO.png

__FP8P8VXLN_Y3__4K762.png

安装

composer require hanson/laravel-admin-qiniu:dev-master -vvv

配置

config/filesystems.php 增加一个 disk

<?php

return [
   'disks' => [
        //...
        'qiniu' => [
           'driver'     => 'qiniu',
           'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
           'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
           'bucket'     => env('QINIU_BUCKET', 'xxx'),
           'domain'     => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
        ],
        //...
    ]
];

使用

<?php

$form = new \Encore\Admin\Form(new Goods);

$form->qiniuImages('column', '商品图')->sortable(); // 普通用法

$form->qiniuImages('column', '商品图')
    ->sortable() // 让图片可以拖拽排序
    ->extraData(['disk' => 'qiniu2', 'path' => 'avatar']) // 假如你有多个七牛配置,可以通过指定此处的 disk 进行上传, path 为文件路径的前缀
    ->value(['http://url.com/a.jpg', 'http://url.com/b.jpg']); // 默认显示的图片数组,必须为 url

$form->saving(function (\Encore\Admin\Form $form) {
    $paths = \Hanson\LaravelAdminQiniu\Qiniu::getPaths(request('qiniu_column')); // 需要 qiniu_ 作为前缀的字段
});