© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Diogo Pinto

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(),
            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?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Form HasOne relationship
FilamentFFilament / ❓┊help
3y ago
how to fill uuid import action bulk
FilamentFFilament / ❓┊help
2y ago
hasOne model relationship select list options
FilamentFFilament / ❓┊help
3y ago
Import Action
FilamentFFilament / ❓┊help
2y ago