Pass the record to the importer class

I’m currently using the importer action in a relation manager. What’s the best way to pass the ownerRecord to the importer and use it in resolveRecord to set the relationship ID accordingly?
ImportAction::make('importSearchQueries')
->iconSize(IconSize::Small)
->label(__('Import'))
->importer(SearchQueriesImporter::class),
ImportAction::make('importSearchQueries')
->iconSize(IconSize::Small)
->label(__('Import'))
->importer(SearchQueriesImporter::class),
->firstOrCreate([
'query' => $this->data['query'],
// Retrieve the ownerRecord?
'relation_id' => 1,
]);
->firstOrCreate([
'query' => $this->data['query'],
// Retrieve the ownerRecord?
'relation_id' => 1,
]);
Solution:
Here is how you can pass data to the importer: ```php ImportAction::make('importSearchQueries') ->importer(SearchQueriesImporter::class)...
Jump to solution
1 Reply
Solution
CodeWithDennis
CodeWithDennis2mo ago
Here is how you can pass data to the importer:
ImportAction::make('importSearchQueries')
->importer(SearchQueriesImporter::class)
->options(['is_cool' => true])
ImportAction::make('importSearchQueries')
->importer(SearchQueriesImporter::class)
->options(['is_cool' => true])
You can then use the following in your importer file.
$this->options['is_cool']
$this->options['is_cool']

Did you find this page helpful?