F
Filamentβ€’2w ago
mounirammi

Import CSV inside a resource page to save exported data to a relationship table.

Hello there. I have an order resource page, and a repeater inside of it to add products to the order page, so Order has Many Product Items, and order items belongs to an Order. I have orders whith more than 200 items, and it's pretty much stressfull to add them one by one using the repeater. So importing a CSV will be a very good option to have in my workflow. Is this posible with the built in importing feature in filament 3 ? Thank you
1 Reply
ebrahimimami
ebrahimimamiβ€’5d ago
As mentioned in official document, the built-in Import feature of Filament, only supports BelongTo relationships. https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#importing-relationships Since your relationship from Order to ProductItem is HasMany which is noy supported, but fortunately you have the chance to swim against the river's stream πŸ€“. Tip: Instead of importing Orders first, Import Order Items first πŸ˜‰ You can define your importer for ProductionItems, and define some columns with order relationship of ProductItem model, which is a BelongsTo relationship.