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
You can install the package via composer:
composer require eightynine/filament-excel-import
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(),
];
}
}
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(),
];
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.