PHP code example of terranc / laravel-admin-qiniu

1. Go to this page and download the library: Download terranc/laravel-admin-qiniu library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

terranc / laravel-admin-qiniu example snippets




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
        ],
        //...
    ]
];



$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_ 作为前缀的字段
});