Must <foreign_model>_id be fillable to save it on resource creation?
I have two models, Opportunity -> belongsTo -> Company. The
opportunities
table has a company_id
field which is * not nullable* to ensure data integrity. The Opportunity
model has a relationship company
.
Note that company_id
is not included in $fillable
, as other sections of my app outside the Filament admin panel should not be able to alter this relationship through requests.
My OpportunityResource::form
field for the relationship:
On the EditOpportunity
page, I can alter the associated company just fine. On CreateOpportunity
however, I can select a company but I get this error:
If I add company_id
to Opportunity::$fillable
, it works as expected.
I'd expect consistent behavior between Create and Edit, so either require company_id
in $fillable
on both operations or on neither.0 Replies