inmanturbo/volt-csv-import-field-mapper
Composer 安装命令:
composer require inmanturbo/volt-csv-import-field-mapper
包简介
Component to allow user to map fields for csv imports
README 文档
README
Component to allow user to map fields for csv imports
Tailwind Purge
'./vendor/inmanturbo/volt-csv-import-field-mapper/resources/views/**/*.blade.php',
Usage
use Illuminate\Support\Facades\Storage; use Spatie\SimpleExcel\SimpleExcelReader; use Inmanturbo\ImportFieldMapper\ImportFieldMapper; use App\Models\Contact; use function Livewire\Volt\{on, state}; state([ 'importMap' => [ 'display_name' => 'Display Name', 'email' => 'Email', ], 'uploadDialog' => false, ]); on([ 'import-field-mapper-updated-uploaded-file' => fn($uploadedCsvPath) => $this->uploadedCsvPath = Storage::path( config('import-field-mapper.path') . DIRECTORY_SEPARATOR . $uploadedCsvPath ), 'import-field-mapper-updated-mapped-import-fields' => fn($mappedImportFields) => $this->mappedImportFields = $mappedImportFields, ]); $importCsv = function () { $path = Storage::path(config('import-field-mapper.path'). '/' . $this->uploadedCsvFile); $reader = SimpleExcelReader::create($path); $reader->getRows()->each(function ($row) { $row = ImportFieldMapper::row($row)->toArray(); $action = new class($row, $this->importMap, $this->mappedImportFields) { use \Inmanturbo\ImportFieldMapper\HandlesMappedEloquentAttributes; protected modelClass() { return \App\Models\Contact::class; } } $action->handle(); }); $this->uploadedCsvFile = null; $this->uploadDialog = false; $this->banner($reader->getRows()->count() . ' Contacts imported successfully'); }; <div> <x-button wire:click="$set('uploadDialog', true)" type="file" class="justify-center w-full space-x-1 sm:w-40"> {{_('Upload Csv')}} </x-button> <x-dialog-modal wire:model="uploadDialog" maxWidth="full"> <x-slot name="title"> {{ __('Import Contacts from CSV file') }} </x-slot> <x-slot name="content"> @livewire('import-field-mapper', ['importFieldMap' => $this->importMap,]) </x-slot> <x-slot name="footer"> <x-secondary-button wire:click="$set('uploadDialog', false)" wire:loading.attr="disabled"> {{ __('Cancel') }} </x-secondary-button> <x-button class="ml-3" wire:click="importCsv" wire:loading.attr="disabled"> <div wire:loading> <svg class="w-4 mr-2 animate-spin" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" fill="none" stroke-width="3"><circle cx="14" cy="14" r="12" stroke="currentColor" class="opacity-25"></circle><path d="M26 14c0-6.627-5.373-12-12-12" stroke-linecap="round" stroke="currentColor" class="opacity-75"></path></svg> </div> {{ __('Save') }} </x-button> </x-slot> </x-dialog-modal> </div>
inmanturbo/volt-csv-import-field-mapper 适用场景与选型建议
inmanturbo/volt-csv-import-field-mapper 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 1.6k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 inmanturbo/volt-csv-import-field-mapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inmanturbo/volt-csv-import-field-mapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-25