F
Filament4mo ago
Frans

Override creation in Importer

My Client model does not have a foo column, however, my import file does and for some reason, it must not be removed because it will be saved in another table. I am using the built-in importer. Is there any workaround to adjust the creation attributes? Or should I go test other import packages such as the handleRecordCreation() of konnco/filament-import? I tried doing it in resolveRecord() but id throws an error 'Column not found foo'
public static function getColumns(): array
{
return [
Import::Column::make('name'),
Import::Column::make('contact'),
Import::Column::make('foo'),
]
}
public static function getColumns(): array
{
return [
Import::Column::make('name'),
Import::Column::make('contact'),
Import::Column::make('foo'),
]
}
public function resolveRecord(): ?Client
{
return new Client([
'name' => $this->data['contact'],
'contact' => $this->data['contact'],
]);
}
public function resolveRecord(): ?Client
{
return new Client([
'name' => $this->data['contact'],
'contact' => $this->data['contact'],
]);
}
public function afterSave(): void
{
Bar::create(['x' => $this->data['foo']);
}
public function afterSave(): void
{
Bar::create(['x' => $this->data['foo']);
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server