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
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server