return $table
->query(Invoice::query()
->when(
Invoice::has('client'),
function ($query) {
$query->whereHas('client', function ($query) {
$query->where('origin', 'internet');
});
}
)
->where('date', '>=', Carbon::now()->subYear()->format('Y-m-d'))
)
->defaultGroup('client.company_name')
->groupsOnly()
->columns([
Tables\Columns\TextColumn::make('sub_total')->summarize(Sum::make()->label('Sub Total')),
Tables\Columns\TextColumn::make('budgetProfit')->summarize(Sum::make()->label('Budget Profit')),
Tables\Columns\TextColumn::make('profit')->summarize(Sum::make()->label('Profit')),
]);
return $table
->query(Invoice::query()
->when(
Invoice::has('client'),
function ($query) {
$query->whereHas('client', function ($query) {
$query->where('origin', 'internet');
});
}
)
->where('date', '>=', Carbon::now()->subYear()->format('Y-m-d'))
)
->defaultGroup('client.company_name')
->groupsOnly()
->columns([
Tables\Columns\TextColumn::make('sub_total')->summarize(Sum::make()->label('Sub Total')),
Tables\Columns\TextColumn::make('budgetProfit')->summarize(Sum::make()->label('Budget Profit')),
Tables\Columns\TextColumn::make('profit')->summarize(Sum::make()->label('Profit')),
]);