Access the current tenant in the importer resolveRecord() method
I'm using filament multitenancy. And I created an import for users. However, when I try to access the current tenant in the resolveRecord method to associate the user with the team I get Call to a member function members() on null.
My team model has
3 Replies
Bumping this.
It doesn't look like I have access to the current tenant in the importer.
Just read in the docs that only a belongsTo relationship works with the importer. But I have a many to many. Anyone know how to go about saving a many to many relationship when importing?
Yes @Frank Wiebe use the hooks provided on the documentation. You have a bunch of them, and you can create relationships on the record you just created or are about to create.
You can set options on the action, which are serialized in the jobs table and can be accessed via the importer $this->options, so you can set the tenant_id there:
https://discord.com/channels/883083792112300104/1179875310221660251/1235250103284138004
Would not be a good idea to get the current tenant incase the tenant switches before the job completes π
P.S Hooks are of no use as they are executred by the queue worker, so wont have access to tenant either