PHP code example of romansulzhyk / filament-import
1. Go to this page and download the library: Download romansulzhyk/filament-import library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
romansulzhyk / filament-import example snippets
use RomanSulzhyk\FilamentImport\Actions\ExcelImportAction;
class ListCustomers extends ListRecords
{
protected function getHeaderActions(): array
{
return [
ExcelImportAction::make(),
];
}
}
ExcelImportAction::make()
->importColumns(['name', 'email', 'phone']) // only these, and only if fillable
->exceptColumns(['role', 'is_admin']); // never these
class ContactImporter extends Importer
{
// ...columns...
protected function beforeSave(): void
{
$this->record->team()->associate(Filament::getTenant());
}
}
ExcelImportAction::make()->importer(ContactImporter::class);