首页 文章

Laravel Nova - 显示更新关系的名称

提问于
浏览
0

我有一个递归关系,其中model Question 与表本身有一对多的关系 . parent_question_id 列将引用 questions 表中的 id .

Question model

/**
 * Get the parent that owns the question.
 */
public function parent()
{
    return $this->belongsTo('App\Question', 'parent_question_id');
}

Question resource

public function fields(Request $request)
{
    return [
        BelongsTo::make('Parent', 'parent', '\App\Nova\Question'),
        ...
    ];
}

上面的代码显示 Question ,而不是更新时的 Parent . 它在索引和详细信息页面上都可以 .

是否有任何功能可用于更新字段的显示名称值?

Laravel Nova版本 - 1.0.16

1 回答

  • 0

    我试过设置 label 并没有用 . 但设置 singularLabel 对我有用 .

    BelongsTo::make('Parent', 'parent', '\App\Nova\Question')
                    ->withMeta(['singularLabel' => 'Parent']),
    

    Update

    问题不再出现在v1.1.7中

相关问题