Import action - fill relationship hasone

Hey all,

I'm trying to import a CSV that has a price relationship (hasOne). This is how I'm trying to do it:

            ImportColumn::make('price')
                ->fillRecordUsing(function (Product $record, string $state): void {
                    $record->price_id = $record->price()->create([
                        'price' => $state,
                        'type' => 'one_time',
                    ])->id;
                })
                ->integer(),


Thing is, obviously, the $record->price can't be created because the record hasn't been assigned an ID yet.

How can I approach this? Is it even possible with the Import action?
Was this page helpful?