Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lara28580's avatar

How to properly import an array via Filament 3 importer

Hey guys, I am using Filament 3, more precisely the Import/Export function. When Exporting the data through a CSV everything works well. When I try to import the same CSV file, everything also works well besides one field. The specific field is the only field containing an array, every othe field conatins text. I am having trouble understanding, why Filament 3 is not able to correctly import the information from the array-field. In my DB it looks like this:

"[{\"cost\":0,\"name\":\"Laundry\",\"period\":\"per-month\"},{\"cost\":0,\"name\":\"Parking\",\"period\":\"per-month\"},{\"cost\":0,\"name\":\"Storage Rental\",\"period\":\"per-month\"}]"

but this is not the wanted result. I am getting the following exception when trying to show the resource

foreach() argument must be of type array|object, string given

This is the wanted result of how an import should look like

[{"cost": 0, "name": "Laundry", "period": "per-month"}, {"cost": 0, "name": "Parking", "period": "per-month"}, {"cost": 0, "name": "Storage Rental", "period": "per-month"}]

In my Importer class

ImportColumn::make('other_income')
                ->rules(['nullable']),

In my Exporter class

ExportColumn::make('other_income'),
0 likes
0 replies

Please or to participate in this conversation.