orlyapps / nova-belongsto-depend

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

Collision with package arsenaltech/nova-tab #25

Closed carloscgo closed 5 years ago

carloscgo commented 5 years ago

I have a collision with use package arsenaltech/nova-tab, the field province no found. But when remove this tab the field work perfect.

image

CasperLaiTW commented 5 years ago

which version you used in nova-tab and nova-belongsto-depend?

I tried in nova-tab(0.2.0) and nova-belongsto-depend(master) and working well.

can you provide code and specific description?

emilianotisato commented 5 years ago

Same issue here: "arsenaltech/nova-tab": "^0.2.0", "orlyapps/nova-belongsto-depend": "^0.0.6",

I don't understand why

CasperLaiTW commented 5 years ago

Can you provide fields method code in the resource?

emilianotisato commented 5 years ago

Hello @CasperLaiTW, this is what I have inside the fields() method in the resource class:

       BelongsTo::make('Operation')->rules('required'),
       BelongsTo::make('Currency')->rules('required'),
       Number::make('Amount')->min(1)->max(999999999999)->step(1)->rules('required'),
       NovaBelongsToDepend::make('Zone')->options(\App\Zone::all())->onlyOnForms(),
       NovaBelongsToDepend::make('Area')->optionsResolve(function ($zone) {
                return $zone->areas()->get(['id','name']);
            })->dependsOn('Zone')->rules('required')->hideFromIndex(),
carloscgo commented 5 years ago

My code is used nova-tab, i retrieve error "Can not find the Field "province" in the Model "App\Nova\Customers":

            new NovaTab('Address Information', [
                NovaBelongsToDepend::make('Country')
                    ->options(\App\Models\Countries::all())
                    ->rules('required'),

                NovaBelongsToDepend::make('Province')
                    ->optionsResolve(function ($country) {
                        return $country->Provinces()->select(['id', 'exonimo_en AS name'])->get(['id', 'name']);
                    })
                    ->dependsOn('Country')
                    ->rules('required'),

                Text::make('City')
                    ->hideFromIndex()
                    ->rules('required', 'max:45'),

                Text::make('Zip Code', 'zip_code')
                    ->hideFromIndex()
                    ->rules('required', 'max:10'),

                Place::make('Address')
                    ->rules('required')
                    ->hideFromIndex(),
            ]),
CasperLaiTW commented 5 years ago

Hi @emilianotisato @carloscgo

I fixed from my local, so I didn't get the issue, and now I create PR for the issue.

you can use my fork before @orlyapps accepted PR

https://github.com/CasperLaiTW/nova-belongsto-depend

CasperLaiTW commented 5 years ago

Guys, you can update composer.json

composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:CasperLaiTW/nova-belongsto-depend.git"
        },
    ],
    "require": {
        "orlyapps/nova-belongsto-depend": "dev-master",
    }
}