orlyapps / nova-belongsto-depend

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

Support: Many To Many Relationship between fields #71

Open Peterragheb opened 4 years ago

Peterragheb commented 4 years ago

I'm trying to use this package for many to many relationship I have a Platform belongsToMany Project and Project belongsTo many Platform

NovaBelongsToDepend::make('Project', 'project', Project::class),

NovaBelongsToDepend::make('Affected Platforms','affectedPlatforms',SupportedPlatform::class)
                ->optionsResolve(function ($project) {
                    return \App\SupportedPlatform::whereHas('projects', function ($q) use ($project) {
                        $q->where('project_id', $project->id);
                    })->get();
                })
            ->dependsOn('Project')
            ->rules('required'),

But I get Method Illuminate\Database\Eloquent\Collection::getKey does not exist.

What am I doing wrong? Also is it possible to select multiple options?

deepraj-sinha commented 3 years ago

@Peterragheb did you got any solution?

ArduanovDanil commented 2 years ago

@orlyapps, hello! I have same issue. Is there any solution?

ikramooe commented 2 years ago

Having the same issue

dan-lutd commented 2 years ago

I also get the error