eightynine / filament-excel-import
Import Excel files with Laravel Filament.
Requires
- php: ^8.1
- filament/filament: ^3.0
- illuminate/contracts: ^10.0|^11.0
- maatwebsite/excel: ^3.1
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9|^8.1
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
This package adds a new feature to your filament resource, allowing you to easily import data to your model
This package brings the maatwebsite/laravel-excel functionalities to filament. You can use all the maatwebsite/laravel-excel features in your laravel project
Installation
You can install the package via composer:
composer require eightynine/filament-excel-import
Usage
Before using this action, make sure to allow Mass Assignment for your model. If you are doing a custom import, this is not necessary.
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Client extends Model { /** * The attributes that are mass assignable. * * @var array */ protected $fillable = ['name', 'phone', 'email']; }
For example, if you have a 'ClientResource' in your project, integrate the action into ListClients class as demonstrated below:
namespace App\Filament\Resources\ClientResource\Pages; use App\Filament\Resources\ClientResource; use Filament\Actions; use Filament\Resources\Pages\ListRecords; class ListClients extends ListRecords { protected static string $resource = ClientResource::class; protected function getHeaderActions(): array { return [ EightyNine\ExcelImport\ExcelImportAction::make() ->color("primary"), Actions\CreateAction::make(), ]; } }
Custom Import
If you wish to use your own import class to change the import procedure, you can use your own Import class.
php artisan make:import MyClientImport
Then in your action use your client imeport class
protected function getHeaderActions(): array { return [ \EightyNine\ExcelImport\ExcelImportAction::make() ->slideOver() ->color("primary") ->use(App\Imports\MyClientImport::class), Actions\CreateAction::make(), ]; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.