nova-belongsto-depend icon indicating copy to clipboard operation
nova-belongsto-depend copied to clipboard

depend On Relationship not found

Open radwanic opened this issue 5 years ago • 3 comments

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?

radwanic avatar Sep 02 '19 14:09 radwanic

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

mfairch avatar Dec 27 '19 16:12 mfairch

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

radwanic avatar Dec 27 '19 19:12 radwanic

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

mfairch avatar Dec 27 '19 19:12 mfairch