-
-
Notifications
You must be signed in to change notification settings - Fork 87
Description
I'm trying to import records into a link model similar to
- id
- class_id
- student_id
- some_other_fields
My Nova Resource has fields of
ID::make()->sortable(),
BelongsTo::make('Class'),
BelongsTo::make('Student'),
...,
The import process looks great all the way up to the import then returns an error with class_id
{ "errorInfo": [ "HY000", 1364, "Field 'class_id' doesn't have a default value" ], "connectionName": "mysql" }
I think this is caused by the BelongsTo Class field being mapped to the class
relation name rather than the class_id
model field.
On the Configure screen the fields are showing as
- Class (class)
- Student (student)
rather than
- Class (class_id)
- Student (student_id)
As such the import is failing as the model needs values for class_id
and student_id
If this is the case, I'm not sure how to solve/work around this. Hopefully I'm missing something obvious.
UPDATE:
If I change my resource fields to ...
ID::make()->sortable(),
BelongsTo::make('Class'),
Number::make('Class', 'class_id'),
BelongsTo::make('Student'),
Number::make('Student', 'student_id'),
...
I can then get the import to work, which seems to prove my theory, but is not a useable workaround as I don't want those number fields in my resource.