Laravel Excel 3.1 怎么样导出图片的?

<?php

namespace App\Exports;

use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithHeadings;

class CollectionsExport implements FromCollection, WithMapping, WithHeadings, ShouldAutoSize
{
    use Exportable;

    protected $collections;

    public function __construct($collections)
    {
        $this->collections = $collections;
    }

    public function collection()
    {
        return $this->collections;
    }

    public function map($collection): array
    {
        return [
            $collection->id,
            $collection->name,
            $collection->identity_card . ' ',
            $collection->gender_name,
            $collection->household_register,
            $collection->residential_district,
            $collection->unit_number,
            $collection->corridor_number,
            $collection->door_number,
            $collection->identity_card_images[0] ?? null,
            $collection->identity_card_images[1] ?? null,
            $collection->personnel_images[0] ?? null,
            $collection->personnel_images[1] ?? null,
            $collection->personnel_images[2] ?? null,
            $collection->created_at->toDateTimeString(),
            $collection->status_name,
        ];
    }

    /**
     * @return array
     */
    public function columnFormats(): array
    {
        return [
            'C' => NumberFormat::FORMAT_TEXT,
            //'C' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE,

        ];
    }

    public function headings(): array
    {
        return [
            'ID',
            '姓名',
            '身份证号码',
            '性别',
            '户籍',
            '现住小区',
            '单元号',
            '楼道号',
            '门牌号',
            '身份证相片正面',
            '身份证相片反面',
            '人员相片1',
            '人员相片2',
            '人员相片3',
            '提交时间',
            '审核状态',
        ];
    }
}

我的照片是一个URL地址来的,怎么样可以导出相片呢?

附言 1  ·  4年前

怎么样把数据转为字符串?
'C' => NumberFormat::FORMAT_TEXT,
这样子好象没有效果,我现在做法是加了一个空格

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 2

什么意思,问题描述不清楚,我看得有点懵,我还以为你要洗出相片呢?

4年前 评论
半人间 (楼主) 4年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!