0

I have a recursive relationship, where model Question has one to many relationship to table itself. Column parent_question_id will refer to id in questions table.

In Question model :

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

In Question resource :

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

Above code displays Question, instead of Parent on update. It is ok on index & detail pages.

enter image description here

Is there any function I can use to update the display name value for field ?

Laravel Nova version - 1.0.16

Saumini Navaratnam
  • 8,439
  • 3
  • 42
  • 70

1 Answers1

1

I have tried setting label & didn't work. But setting singularLabel works for me.

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

Update

The issue is no longer in v1.1.7

Saumini Navaratnam
  • 8,439
  • 3
  • 42
  • 70