Nova - ManyToMany with additional relationships

85 Views Asked by At

So, we have a contacts table and a projects table, with a many to many relationship. the pivot table contact_project has a answer_type_id so it belongsTo AnswerType, and it also HasMany sendings.

I'm trying to allow content people to link contacts to projects. So I added:

BelongsToMany::make('Projects')
                ->fields(function ($request, $relatedModel) {
                    return [
                        BelongsTo::make('Answer type'),
                        DateTime::make('Answered at')
                    ];
                }),

And I also tried to define the belongsTo as BelongsTo::make('Answer type', 'answerType', ContactProject::class) but to no avail : Call to undefined method App\Models\Contact::answerType().

I would be grateful for a little help :) Thanks ahead!

1

There are 1 best solutions below