© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
morawcik

Pivot data in model/resource table

Hi.
I have Product model with relation:
public function customerGroups(): BelongsToMany
{
    return $this->belongsToMany(CustomerGroup::class, "customer_group_product")
      ->withPivot(['purchasable', 'visible', 'enabled', 'starts_at', 'ends_at'])->withTimestamps();
}
public function customerGroups(): BelongsToMany
{
    return $this->belongsToMany(CustomerGroup::class, "customer_group_product")
      ->withPivot(['purchasable', 'visible', 'enabled', 'starts_at', 'ends_at'])->withTimestamps();
}

I tried to show
purchasable
purchasable
in resource table but without success. I added column:
Tables\Columns\TextColumn::make('customerGroups.pivot.purchasable')
    ->badge()
    ->label('purchasable')
Tables\Columns\TextColumn::make('customerGroups.pivot.purchasable')
    ->badge()
    ->label('purchasable')

but it is always empty. When i change it to
customerGroups.name
customerGroups.name
the I get those names.
I even tried to dump
$state
$state
inside of
color()
color()
method. I started with just
customerGroups
customerGroups
and I got this:
{"id":1,"name":"Detal","handle":"detal","default":1,"attribute_data":null,"created_at":"2023-07-31T21:53:13.000000Z","updated_at":"2023-08-02T20:48:21.000000Z","pivot":{"product_id":142,"customer_group_id":1,"purchasable":1,"visible":1,"enabled":1,"starts_at":null,"ends_at":null,"created_at":"2023-08-13T08:33:37.000000Z","updated_at":"2024-05-30T18:26:16.000000Z"}}
{"id":1,"name":"Detal","handle":"detal","default":1,"attribute_data":null,"created_at":"2023-07-31T21:53:13.000000Z","updated_at":"2023-08-02T20:48:21.000000Z","pivot":{"product_id":142,"customer_group_id":1,"purchasable":1,"visible":1,"enabled":1,"starts_at":null,"ends_at":null,"created_at":"2023-08-13T08:33:37.000000Z","updated_at":"2024-05-30T18:26:16.000000Z"}}

and then if i tried
customerGroups.pivot
customerGroups.pivot
or
customerGroups.pivot.purchasable
customerGroups.pivot.purchasable
I got nothing - like
dd()
dd()
even not fired
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

Insert Data in Pivot Table
FilamentFFilament / ❓┊help
3y ago
save repeater data in pivot table
FilamentFFilament / ❓┊help
2y ago
Sort data in Resource Table
FilamentFFilament / ❓┊help
3y ago
Update data on pivot table
FilamentFFilament / ❓┊help
2y ago