© 2026 Hedgehog Software, LLC

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

Custom text columns, calculated values, sum of related table values.

Hi,
I have:

Model: Booking
public function deals(): hasMany
{
    return $this->hasMany(Deal::class);
}
public function deals(): hasMany
{
    return $this->hasMany(Deal::class);
}


Model: Deal
public function booking(): belongsTo
{
    return $this->belongsTo(Booking::class);
}
public function booking(): belongsTo
{
    return $this->belongsTo(Booking::class);
}


My booking view shows this table (part of it).

I have some questions, please read the comments.

Tables\Columns\ColumnGroup::make('Deals', [

    //Works as wanted, shows how many deals I have per booking.
    Tables\Columns\TextColumn::make('deals_count')
        ->counts('deals'),

    //Works as wanted, shows the price of each deal per booking
    Tables\Columns\TextColumn::make('deals.price')
        ->label('Each Deal Price')
        ->listWithLineBreaks()
        ->money('gbp', divideBy: 100),

    //How can I calculate the sum of all deals?
    Tables\Columns\TextColumn::make('???')
        ->label('All Deals Prices Sum')
        -???,

    //Works as wanted (different VAT values are stored in the DB)
    Tables\Columns\TextColumn::make('vat')
        ->label('VAT')
        ->suffix('%'),

    //How can I calculate the sum of all deals plus the value of the VAT?
    Tables\Columns\TextColumn::make('???')
        ->label('All Deals Prices Sum + VAT')
        ???,

])
Tables\Columns\ColumnGroup::make('Deals', [

    //Works as wanted, shows how many deals I have per booking.
    Tables\Columns\TextColumn::make('deals_count')
        ->counts('deals'),

    //Works as wanted, shows the price of each deal per booking
    Tables\Columns\TextColumn::make('deals.price')
        ->label('Each Deal Price')
        ->listWithLineBreaks()
        ->money('gbp', divideBy: 100),

    //How can I calculate the sum of all deals?
    Tables\Columns\TextColumn::make('???')
        ->label('All Deals Prices Sum')
        -???,

    //Works as wanted (different VAT values are stored in the DB)
    Tables\Columns\TextColumn::make('vat')
        ->label('VAT')
        ->suffix('%'),

    //How can I calculate the sum of all deals plus the value of the VAT?
    Tables\Columns\TextColumn::make('???')
        ->label('All Deals Prices Sum + VAT')
        ???,

])


Please, any advice is much appreciated,
Thank you,
Pablo
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

Summarize Sum of a calculated field
FilamentFFilament / ❓┊help
2y ago
Getting SUM of related table column not working
FilamentFFilament / ❓┊help
2y ago
Custom Table Values
FilamentFFilament / ❓┊help
17mo ago
Table columns footer not being calculated using getTableContentFooter()
FilamentFFilament / ❓┊help
3y ago