F
Filament2mo ago
ericmp

How to get ownerRecord inside RecordImporter?

Lets setup 2 models. Event & People. The relationship is n to n. Inside the edit component of the event resource i added a relation manager - PeopleRelationManager. Now i started to configure the PeopleImporter so my users can import people into the event they are editing. The question is, can I somehow get the ownerRecord so i can attach the people imported to the current event? So far it works (the models are created), but the people arent attached to the event this is how it looks so far:
->headerActions([
Tables\Actions\ImportAction::make('importPeople')->importer(PeopleImporter::class),
])
->headerActions([
Tables\Actions\ImportAction::make('importPeople')->importer(PeopleImporter::class),
])
now i'm trying to pass in somehow the id of the event, but idk how to retrieve it inside the PeopleImporter class:
->headerActions([
Tables\Actions\ImportAction::make('importPeople')->importer(PeopleImporter::class)->call([
'ownerRecord' => $this->getOwnerRecord(),
]),
])
->headerActions([
Tables\Actions\ImportAction::make('importPeople')->importer(PeopleImporter::class)->call([
'ownerRecord' => $this->getOwnerRecord(),
]),
])
5 Replies
ericmp
ericmp2mo ago
bump
Vp
Vp2mo ago
I've never tried Import, but if this "PeopleImporter" is a livewire then you may get using mount()
ericmp
ericmp2mo ago
not sure if it is, its a class that extends vendor/filament/actions/src/Imports/Importer.php im just following the docs but not sure if what im trying to achieve is possible to achieve bump ^^
Dan Harrin
Dan Harrin2mo ago
have you tried passing it as an option? isnt there a section about importing relation managers
ericmp
ericmp2mo ago
sorry for not updating the question, like half an hour i discovered it! yeah now i do:
public function resolveRecord(): ?Contact
{
$contact = Contact::firstOrNew([
'email' => $this->data['email'],
]);

EventContact::updateOrCreate([
'contact_id' => $contact->id,
'event_id' => $this->options['ownerRecordId'],
]);

return $contact;
}
public function resolveRecord(): ?Contact
{
$contact = Contact::firstOrNew([
'email' => $this->data['email'],
]);

EventContact::updateOrCreate([
'contact_id' => $contact->id,
'event_id' => $this->options['ownerRecordId'],
]);

return $contact;
}
🙏 thanks
->options([
'ownerRecordId' => $this->getOwnerRecord()->id,
])
->options([
'ownerRecordId' => $this->getOwnerRecord()->id,
])
@Dan Harrin but im having an error and i dont undersand where it comes from - https://discord.com/channels/883083792112300104/1246023527019057193/1246023527019057193
Want results from more Discord servers?
Add your server
More Posts
Filter Indicator : ColorHi I wanna know if there's any way to change the color of the FilterIndicator that I'm creatins withAction modalWidth issue ?Setting modalWidth to an action placed in getHeaderActions array doesn't work ?!TimePicker field not allow to set 24 hrs format.```TimePicker::make('picker')->displayFormat('H:i'),``` I tried this but the it not allow to me set filament.exports.download giving 404 in multi-database multi-tenancy setupI am using stancl/tenancy for multi database tenancy with filament. I've not enabled tenant featuresHow to display a lot of data (40.000+) into a select dropdown?Do you have any input? This is the first time I've executed this much data, I don't have experienceGet Relation Fieldset State / Set Outside State in Relationship FieldsetForm resources that have fieldset relationship, how to get state that fieldset on outside? just forColorPicker Required BugGuys, I'm trying to use a color picker inside a Custom Livewire Page, using a form from Filament, aHow to get $data in Tables\Actions\CreateAction::make()?I used to get the $data in the form using ->before(function (RelationManager $livewire, array $data,FileUpload::make()->directory('my/secret/sauce') Don't save full URL in DBI have an existing DB, that stores just the file name for image_loc. 'user1.png' is in my DB. NoIs it no longer possible to call Vite in the Panel Providers asset method?I was getting an exception when a fresh install runs `@php artisan package:discover --ansi` ``` Ill