© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
JonVonWeston

Another newbie question - saving simple pivot table record

Hi folks - apologies for another newbie question - I have 2 tables - vehicle and category - relationship defined as many to many on both models - and I have a simple pivot table category_product that contains just category_id & product_id.

In my create product form I have a select with items sourced from category model - all good
When I save the product record - It is saving the category ID to the product table - great
Back to the table display - and the column category.name isn't showing anything

On investigation, the 'relationship record' in the pivot table isn't being saved - If I manually add the pivot record - boom - table is good and everyone is happy

So my question is two fold

Even though its a simple pivot table with no additional fields - do I need to define withPivot(['category_id','product_id']) on the models?

What do I need to do to tell on create to save the relationship record? I understand that relationship record can't be created until the product has been created due to requiring the product_id

I do have listeners on the product model for other reasons, so I can latch into the onCreate method in there but that feels cumbersome for something as elegant as Filament

What am I doing wrong?

Apologies again for these newbie questions

Jon
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

problem saving pivot table
FilamentFFilament / ❓┊help
3y ago
Update pivot table when editing record
FilamentFFilament / ❓┊help
2y ago
Reordering records with order record in a pivot table
FilamentFFilament / ❓┊help
3y ago
Displaying related pivot record details on table
FilamentFFilament / ❓┊help
2y ago