在我的 laravel nova 资源中,我返回这些字段:
Select::make('department_id')->onlyOnForms()
->options(\App\Models\Department::pluck('title', 'id')),
Select::make('Sector', 'sector_id')->onlyOnForms()->rules(['required'])->dependsOn(['department_id'],
function (Select $field, NovaRequest $request, FormData $formData) {
// query available sectors based on choosed department
if ($formData->department_id)
$field->options(\App\Models\Sector::pluck('title', 'id'));
else
$field->readonly();
}),
Text::make('subject'),
问题是department_id仅用于获取sector_id值,而模型和数据库列中没有该字段。 但是当提交表单时我收到此错误:
未找到列:1054“字段列表”中未知列“department_id” 在....
如何让 nova 在提交时忽略该字段?