#Summarize course revenue

1 messages · Page 1 of 1 (latest)

arctic ridge
#

So I have a Course model and an Enrollment model.

each Course has a fee.

the Course model has a function that calculates the revenue like so:

    public function getRevenueAttribute()
    {
        return $this->enrollments()->where('is_paid', true)->count() * $this->cost;
    }

and I am displaying that data in my table:

TextColumn::make('revenue')
    ->state(fn ($record) => $record->revenue)
    ->numeric(),

I want to display the sum of all course revenues at the bottom of my table but adding this didn't help:

->summarize(Sum::make())

instead I get this error

simple rapids
#

Haya, have you found a way to solve this yet? Im facing the same issue.
Thanks in advance

unborn verge