defining the inverse - Whats's wrong?
Muetze42 opened this issue · comments
Norman Huth commented
I've following One To Many Relation:
/**
* Get the steps for the recipe.
*/
public function steps(): HasMany
{
return $this->hasMany(Step::class);
}
/**
* Get the recipe that owns the step.
*/
public function recipe(): BelongsTo
{
return $this->belongsTo(Recipe::class);
}
And in my recipe resource this package:
NestedForm::make('steps'),
But, if I want to create a new entry, I get this message:
A field defining the inverse relationship needs to be set on your related resource (e.g. MorphTo, BelongsTo, BelongsToMany...)
Where should the error be or does the package have a different idea of a relation than me and the Laravel documentation?
cserepesmark commented
You need to add the following line to fields list in your Nova/Steps resource.
public function fields(Request $request)
{
return [
ID::make(__('ID'), 'id')->sortable(),
BelongsTo::make('recipe'),
];
}
itscoolprakhar commented