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

Nested form not working for MorphTo Relation

jahid56 opened this issue · comments

My Nested form not working for MorphTo Relation
Here is my Model
`
class Profile extends Model
{

public function address()
{
    return $this->morphOne(Address::class, 'addressable');
}

}`

`
class Address extends Model
{

public function addressable()
{
    return $this->morphTo();
}

}
`

and My Nova File Is for Profile.php
`public function fields(Request $request)
{
return [

        Text::make('Company Name', 'company_name')
            ->rules('nullable', 'max:100'),

        NestedForm::make('Address')
                  ->heading('Address'),
    ];
}`

and For Address.php
`public function fields(Request $request)
{
return [

        Place::make('Address', 'street')
            ->rules('required', 'max:255'),

        Text::make('State')
            ->rules('nullable', 'max:50'),

        Text::make('City')
            ->rules('nullable', 'max:50'),

        Text::make('Postal Code')
            ->rules('required', 'max:15'),

        Country::make('Country')
               ->rules('required', 'max:50'),

        MorphTo::make('Profile', 'addressable'),
    ];
}`

But it throws error
A field defining the inverse relationship needs to be set on your related resource (e.g. MorphTo, BelongsTo, BelongsToMany...)

The same Error is given in the project

@yassilah sir

Laravel Nova Display error
A field defining the inverse relationship needs to be set on your related resource (e.g. MorphTo, BelongsTo, BelongsToMany...)
Other
{,…}
In Ajax Form Given Error

exception: "Exception"
file: "/Applications/XAMPP/xamppfiles/htdocs/green-planet-admin/vendor/yassi/nova-nested-form/src/NestedForm.php"
line: 395
message: "A field defining the inverse relationship needs to be set on your related resource (e.g. MorphTo, BelongsTo, BelongsToMany...)"
trace: [{,…},…]