© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Joachim Strand

Tenant user pivot values

Hey, I have a fairly standard tenant setup and I have a users resource to show the tenant users. My "tenant" is a Company. So a company
belongsToMany
belongsToMany
Users and a users
belongsToMany
belongsToMany
Companies with the pivot table having a column
role
role
.

Listing the users is working just fine, but the role is not showing (or none of the pivot values).

This is the relationship on the Users model:

    public function companies(): BelongsToMany
    {
        return $this->belongsToMany(Company::class)
            ->withTimestamps()
            ->withPivot([
                'created_at',
                'updated_at',
                'role',
                'added_by_user_id',
            ])
            ->using(CompanyUserPivot::class);
    }
    public function companies(): BelongsToMany
    {
        return $this->belongsToMany(Company::class)
            ->withTimestamps()
            ->withPivot([
                'created_at',
                'updated_at',
                'role',
                'added_by_user_id',
            ])
            ->using(CompanyUserPivot::class);
    }


I have the same thing on the Company model, just the reverse
users()
users()
.

I have a pivot class that is casting the role to a enum and the
added_by_user_id
added_by_user_id
is a relationship to a user.

I understand that I have to convert the enum into a string, but if I add
TextColumn::make("role")
TextColumn::make("role")
to the table, I expected to get an error saying something like cannot convert enum to string, but I get this instead:

App\Models\User::role must return a relationship instance, but "null" was returned. Was the "return" keyword used?
App\Models\User::role must return a relationship instance, but "null" was returned. Was the "return" keyword used?


Am I missing something essential here? I use pivot values many places like this, but this one was not working.

Let me know if you need more data

Thank you!
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

Wrong Pivot Values
FilamentFFilament / ❓┊help
15mo ago
pivot table user/user
FilamentFFilament / ❓┊help
3y ago
Editing select label with pivot values
FilamentFFilament / ❓┊help
2y ago
attach action form and pivot values
FilamentFFilament / ❓┊help
2y ago