Jean-Loup
import from csv into multiple related tables
Hi folks,
Sorry for asking but I'm really struggling to find any definitive documentation on how to implement this and I'm not even certain that's even possible at least with the ImportAction from Filament.
I have a csv with data we've broken down to be distributed into 6 different tables. I understand the relationship model in the Import action is still in its infancy and only supports belongs_to relationships. However I figured even with that there's no reason I couldn't manage to make my objectives work. So what I'm trying to do is this:
- create records for tables if they don't already exist and retrieve the id of the record to be recorded as a foreign key
- have the import be one single function, not 6 different import actions.
I tried stacking
->importer(MyclassImporter::class)
in the Resource I want the imort button to be in but if I do that it ignores every importer except for the last one (yet doesn't return an error)
Right now I'm trying to define everything under one MyclassImporter.php file and see if I can make relationships work but I'm not having much luck. I tried using dot notation in ImportColumn::make()
but although this doesn't throw an error on screen, it doesn't seem to work either. I was trying to see if perhaps the ->resolveRelatedRecord()
method for the ImportColumn class would work but I can find no documentation at all on how to use that. The Filament docs have nothing at all on this method.
It seems odd to me that there is so little documentation on how to import into multiple tables. Perhaps my search skills have failed me but I would appreciate any guidance you could provide, even if that's just pointing me towards other ways to do this that don't involve Filament. I hope this all makes sense.
Cheers21 replies