yassilah / laravel-nova-nested-form

This package allows you to include your nested relationships' forms into a parent form.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

defining the inverse - Whats's wrong?

Muetze42 opened this issue · comments

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?

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'),
        ];
    }

After defining the inverse relationship it is showing relationship column. Can i hide some how?

image