BelongsTo select save issue
Having an issue with a select input not saving as the correct name, caused by different relationship naming. On create the knowledge_base_category_id select input is correct, when updating it tries to save as category_id. Code breakdown below.
I have two models
KnowledgeBaseArticle
KnowledgeBaseCategory
KnowledgeBaseArticle
KnowledgeBaseCategory
I have the following resource for KnowledgeBaseArticle
9 Replies
I think whats happening is filament is failing to transform the relationship to the knowledge_base_category_id and is instead trying to use the relationship name and appending _id turning into category_id
but only in the update part of the code, not sure how to code dive that to see where the issue would be coming from
this all works if I modify the relationship name to knowledgeBaseCategory so defs something going on there
I think you need to learn from laravel relationship, here is the link https://laravel.com/docs/10.x/eloquent-relationships#one-to-one-defining-the-inverse-of-the-relationship
Specially this line
the relationship is fine i think?
article has a category, category can have many articles
you can override the fk with the second param of belongsTo
You have
KnowledgeBaseCategory
model, not Category
model..
yes.. do thisi already did
wait
š¤¦āāļø
yeah code i pasted was wrong, still the same issue tho
still attempts to insert into category_id
was messing with stuff to see if I was high or something and forgot to re-add that code but still bugged. I'll setup a reproduction repo to sanity check myself š
Solution
ye no im dumb, thanks š