orlyapps / nova-belongsto-depend

Larave Nova BelongsTo Field with Dependcy
MIT License
182 stars 65 forks source link

depend On Relationship not found #49

Open radwanic opened 5 years ago

radwanic commented 5 years ago

Laravel version 5.8 Nova version 2.0

I have Country and City models, and trying to link them together.

NovaBelongsToDepend::make('Country')
    ->options(\App\MyProject\Countries\Country::all()),

NovaBelongsToDepend::make('City')
    ->optionsResolve(function ($country) {
        return $country->cities()->get(['id','name']);
    })
    ->dependsOn('Country'),

I'm getting the following error when I select a country

depend On Relationship not found on the Resource spefified for the Field "city" Please check you have set correct /App/Nova/Resource

The relationship is defined in each model

In Country model I have

public function cities()
{
    return $this->hasMany(City::class, 'country_id');
}

In City model I have

public function country()
{
     return $this->belongsTo(Country::class);
}

I tried to trace it down and didn't succeed. All of my nova resources are placed inside /App/Admin/Resources, I don't think that is related though, but seeing the path /App/Nova/Resource in the error made me wonder.

Any idea what might cause this issue?

mfairch commented 4 years ago

@radwanic I am having the same issue, did you ever figure it out?

radwanic commented 4 years ago

@mfairch nope, stopped using it for the lack of support

mfairch commented 4 years ago

@radwanic did you find an alternative or roll your own?