Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defining the inverse - Whats's wrong? #143

Open
Muetze42 opened this issue Jul 1, 2021 · 2 comments
Open

defining the inverse - Whats's wrong? #143

Muetze42 opened this issue Jul 1, 2021 · 2 comments

Comments

@Muetze42
Copy link

Muetze42 commented Jul 1, 2021

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
Copy link

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
Copy link

itscoolprakhar commented Dec 25, 2022

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants