FilamentF
Filament3y ago
Fonz

Custom column to display a pivot of the current user and tenancy relationship

I would like to display a boolean column of the users and the currenty tenant relation in a table and I am a bit lost. Can someone point me to the right direction? Thanks
Solution
With a bit of help from chatgpt:

User.php
public function getAcceptedForCurrentTenantAttribute()
    {
        $userTenant = $this->tenants->firstWhere('id', \Filament\Facades\Filament::getTenant()->id);
        return $userTenant ? $userTenant->pivot->accepted : 'N/A';
    }

UserResource.php
TextColumn::make('Accepted for Current Tenant', 'acceptedForCurrentTenant')


This seems to work
Was this page helpful?