orlyapps / nova-belongsto-depend

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

Issue on Model name #2

Closed afrars closed 6 years ago

afrars commented 6 years ago

NovaBelongsToDepend::make('State') ->options(\App\Models\State::all()) ->searchable() ->rules('required'),

NovaBelongsToDepend::make('City') ->optionsResolve(function ($state) { return $state->cities; }) ->dependsOn('State') ->searchable() ->rules('required'),

Relation is working fine I am able to get all the cities according the state selection

but it is showing error in below relation

NovaBelongsToDepend::make('TruckBrand') ->options(\App\Models\TruckBrand::all()) ->searchable() ->rules('required'),

NovaBelongsToDepend::make('TruckModel') ->optionsResolve(function ($brand) { return $brand->truckmodels; }) ->dependsOn('TruckBrand') ->searchable() ->rules('required'),

In Laravel model relation is given and working fine with BelongsTo relation.

Thanks in Advance

orlyapps commented 6 years ago

Hello,

This https://github.com/orlyapps/nova-belongsto-depend/commit/b3e5619cb7b1c513fe930cad33c7d80e3f1bc482 should fix your problem.

Can you please try it again? I have also created a demo project: https://github.com/orlyapps/laravel-nova-demo