© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
dascorp

relationship manager on belongs to many with pivot model throws error

I have a following relation on Project::model

public function Members(): BelongsToMany
    {
        return $this->belongsToMany(Member::class)
            ->withPivot('responsibility_id')
            ->using(ProjectMember::class)
            ->with('pivot.responsibility')
            ->leftJoin('responsibilities', 'project_member.responsibility_id', '=', 'responsibilities.id')
            ->orderByPivot('responsibilities.order')
            ->withTimestamps();
    }
public function Members(): BelongsToMany
    {
        return $this->belongsToMany(Member::class)
            ->withPivot('responsibility_id')
            ->using(ProjectMember::class)
            ->with('pivot.responsibility')
            ->leftJoin('responsibilities', 'project_member.responsibility_id', '=', 'responsibilities.id')
            ->orderByPivot('responsibilities.order')
            ->withTimestamps();
    }


when I try to use relation manager I am getting
Call to a member function newCollection() on null
Call to a member function newCollection() on null
error

note that the relationship manager works OK if
Member
Member
data only from pivot table is gathered (when I comment out pivot additions/ relations)


public function Members(): BelongsToMany
    {
        return $this->belongsToMany(Member::class)
            ->withPivot('responsibility_id')
            // ->using(ProjectMember::class)
            // ->with('pivot.responsibility')
            // ->leftJoin('responsibilities', 'project_member.responsibility_id', '=', 'responsibilities.id')
            // ->orderByPivot('responsibilities.order')
            ->withTimestamps();
    }
public function Members(): BelongsToMany
    {
        return $this->belongsToMany(Member::class)
            ->withPivot('responsibility_id')
            // ->using(ProjectMember::class)
            // ->with('pivot.responsibility')
            // ->leftJoin('responsibilities', 'project_member.responsibility_id', '=', 'responsibilities.id')
            // ->orderByPivot('responsibilities.order')
            ->withTimestamps();
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Accessing pivot model relationships in relationship manager
FilamentFFilament / ❓┊help
3y ago
Many relationship manager?
FilamentFFilament / ❓┊help
2y ago
Relation manager Many to Many relationship
FilamentFFilament / ❓┊help
3y ago
Belongs to many showing error
FilamentFFilament / ❓┊help
2y ago