How to use table builder to manage many-to-many relationship

Does anyone have any experience using the table builder package to create a table to manage a many-to-many relationship?

I have a simple many-to-many relationship with one of my models, Profile, and another one, Attributes. I set up the table component to list the profile's attributes.

I set up getTableQuery() to return `Profile::attributes()->getQuery().

This works great....

Then, I add the AttachAction to the table's header actions, and this is where things begin to fall apart:
    protected function getTableHeaderActions(): array
    {
        return [
            Tables\Actions\AttachAction::make()
                ->relationship($this->profile->attributes())
                ->inverseRelationshipName('profile')
                ->recordTitleAttribute('name'),
        ];
    }


Trying to attach an attribute starts out fine: button, modal, dropdown...and when you type something, the generated query works and correctly returns the right data, but then it displays the same (wrong) value for each attribute: 'attribute'.

Does anyone have any experience/examples...? Any suggestions/guidance...? 🤔
Was this page helpful?