waad/filament-import-wizard
Install the package (unchanged):
composer require waad/filament-import-wizard
php artisan vendor:publish --provider="Waad\FilamentImportWizard\FilamentImportWizardServiceProvider" --tag="config"
php artisan vendor:publish --provider="Waad\FilamentImportWizard\FilamentImportWizardServiceProvider" --tag="migrations"
php artisan migrate
Register the import wizard in a Filament resource (updated for new features):
use Waad\FilamentImportWizard\FilamentImportWizard;
public static function getPages(): array
{
return [
// ... other pages
FilamentImportWizard::make('users')
->model(User::class)
->columns([
'name' => 'Name',
'email' => 'Email',
'role' => 'Role',
])
->relationships([
'team' => 'Team Name',
])
->translatableFields(['name', 'description']) // New: Support for translatable fields
];
}
First use case (updated UI flow):
users_import.csv).Title → title).name_en, name_es).Column Mapping (Reverse UI):
UserTitle → user_title).translatableFields() to enable support for Spatie Translatable or native JSON fields:
->translatableFields(['name', 'description'])
->columns(['name', 'email'])
->relationships(['team' => 'Team Name'])
->translatableFields(['name', 'bio'])
Upsert Logic (Fixed):
->upsertKeys(['email'])
->upsertFields(['name', 'updated_at'])
Queue Configuration (Optimized):
normalizeRecordKeys() fix:
->batchSize(1000)
->queueConnection('database')
import_jobs table (new completed_with_errors status).Validation Rules (Enhanced):
->validationRules([
'email' => 'required|email|unique:users,email,{{existing}}',
'role' => 'required|exists:roles,name',
])
name_en|required).Relationship Handling (Fixed):
->relationships([
'team' => 'Team Name',
])
->relationshipModel(Team::class)
resolveFillable() for custom fillable logic if needed.Translatable Fields (New):
name_en,name_es,email
John,Juan,john@example.com
name_en and name_es into a single field.Standalone Usage (Unchanged):
use Waad\FilamentImportWizard\Components\ImportWizard;
public function mount()
{
ImportWizard::make('standalone_import')
->model(Product::class)
->columns(['name', 'price'])
->translatableFields(['name'])
->mount();
}
resources/views/vendor/filament-import-wizard.mapping.blade.php template now uses a reverse layout (model fields first).ImportAction (unchanged).getTranslatableFields() to detect translatable fields programmatically.->tenant(fn () => Auth::user()->currentTeam)
ImportStarted, ImportCompleted, or ImportFailed (unchanged).created, updated) now fire during imports.Reverse Mapping Confusion:
UserTitle → user_title) to speed up mapping.Translatable Field Setup:
name_en, name_es).->translatableFields(['name'])
field_locale (e.g., name_en).Guarded Model Relationships:
$guarded = [].resolveFillable() or ensure relationships are in $fillable:
->relationships(['team' => 'Team Name'])
->resolveFillable(fn () => array_merge($this->model->fillable, ['team_id']))
Memory Limits (Mitigated):
batchSize or chunk files server-side.Validation Overrides:
skipValidation() or adjust rules carefully:
->validationRules(['email' => 'required|email'])
->skipValidation(['email']) // Skip auto-validation
Log Imports:
'debug' => env('FILAMENT_IMPORT_WIZARD_DEBUG', false),
Log::debug instead of Log::warning in production.Test with Small Files:
Check Job Payloads:
import_jobs table for serialized payloads.completed_with_errors status if imports fail silently.Translatable Field Debugging:
field_locale pattern (e.g., title_en).Custom Import Actions:
ImportAction to add pre/post-import logic (unchanged).insertRecordsAsModels() to trigger Eloquent events:
class CustomImportAction extends ImportAction
{
protected function afterImport(ImportJob $job)
{
event(new ImportCompleted($job, $results));
}
}
Custom Column Types:
ColumnType interface (unchanged).Presets (Enhanced):
->presets([
'users' => [
'columns' => ['name', 'email'],
'relationships' => ['team'],
'translatableFields' => ['name', 'bio'],
],
])
Webhooks:
ImportCompleted events to trigger external actions (unchanged).How can I help you explore Laravel packages today?