laravel-admin文件上传 数据导出excel

laravel-admin文档写的非常详尽,,如果不是特殊需求根本不需要额外查询资料,这里只写一下自己习惯 方便自己快速使用,读者建议看文档走一遍。

文件上传

laravel-admin中文文档-文件上传链接

config/filesystems.php

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],
        'admin' => [
	        'driver'     => 'local',
	        'root'       => public_path(),
	        'visibility' => 'public',
	        'url' => env('APP_URL').'/',
	    ],

    ],

控制器表单:

$form->multipleImage('hetong', __('合同'))->move('/upload/hetong/'.date('Y-m-d H:i:s'))->removable()->sortable();

数据导出excel

laravel-admin中文文档-数据导出链接

$grid->export(function ($export) {
            // var_dump($export);exit;
            $export->filename('Filename.csv');
        
            // $export->except(['column1', 'column2' ]);
        
            // $export->only(['column3', 'column4' ]);
        
            $export->originalValue([ 'statusx','zhouqi']);
        
            $export->column('cpname', function ($value, $original) {
                return $original;
            });
            
        });

0 评论
内联反馈
查看所有评论