承接 quickhelper/quickexcelimport 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

quickhelper/quickexcelimport

最新稳定版本:v1.0.0

Composer 安装命令:

composer require quickhelper/quickexcelimport

包简介

A Laravel package for importing Excel files into Eloquent models with support for Filament

README 文档

README

A flexible Laravel package for importing Excel files into Eloquent models with support for Filament.

Installation

composer require quickhelper/quickexcelimport

Publish Configuration

php artisan vendor:publish --tag=excel-import-config

Basic Usage

Create an Importer

Create a class that extends the BaseImport class:

<?php

namespace App\Imports;

use App\Models\Product;
use QuickExcelImport\ExcelImport\BaseImport;

class ProductImport extends BaseImport
{
    protected $condition = 'sku'; // Column to use for finding existing records

    public function __construct($filePath, $overwrite = false)
    {
        parent::__construct($filePath, new Product(), $overwrite, $this->condition);
    }

    public function handle($row)
    {
        // Transform the data before importing
        return [
            'name' => $row['name'],
            'sku' => $row['sku'],
            'price' => $row['price'],
            'description' => $row['description'],
            // Add more fields as needed
        ];
    }
}

Using with Filament

Add the import action to your Filament resource:

<?php

namespace App\Filament\Resources;

use App\Filament\Resources\ProductResource\Pages;
use App\Imports\ProductImport;
use Filament\Resources\Resource;
use QuickExcelImport\ExcelImport\BaseFilamentAction;

class ProductResource extends Resource
{
    // Your resource configuration...

    public static function getActions(): array
    {
        $data = [
            'importer' => ProductImport::class,
            'label' => 'Import Products',
            'can' => auth()->user()->can('import products'),
            'form' => [
                // Add additional form fields if needed
            ],
        ];

        return [
            BaseFilamentAction::action($data),
        ];
    }
}

Features

  • Import Excel files into Eloquent models
  • Handle validation and error reporting
  • Support for overwriting existing records
  • Integration with Filament for UI
  • Customizable error handling and reporting
  • Export errors to Excel for easy debugging

License

The MIT License (MIT). Please see License File for more information.

Best regards,
Yossef Ashraf

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-03