Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JerryBels's avatar

Nova - ManyToMany with additional relationships

Hey people :) 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!

0 likes
1 reply

Please or to participate in this conversation.