Need Help, How to use Count Summarize
So i have table like this
and the result like the image, I think the summary that each group by date is not appropriate, how can I solve it?
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('date_register')->label('Bulan')->date('l, jS F Y'),
Tables\Columns\TextColumn::make('type')->label('Jumlah')->summarize(
Count::make()->query(fn (Database\Query\Builder $query) => $query->groupBy('type'))->label('')
),
])
->filters([
//
])
->actions([
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->defaultGroup(
// Group the rows by Year and Month (2023-09, 2023-11 etc) instead of "date"
Group::make('date_register')
// Ex: "2023-10-0",
// Note: You need the "-0" at the end, so Carbon can parse the date.
->getKeyFromRecordUsing(
fn(RegistrationData $record): string => $record->date_register
)
// Ex: "September 2023"
->getTitleFromRecordUsing(
fn(RegistrationData $record): string => $record->date_register->format('F Y')
)
// Set the default ordering
->orderQueryUsing(
fn(Builder $query, string $direction) => $query->orderBy('date_register', 'asc')
)
// Hide "date: " in the Group title
->titlePrefixedWithLabel(false)
->collapsible(),
);
} public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('date_register')->label('Bulan')->date('l, jS F Y'),
Tables\Columns\TextColumn::make('type')->label('Jumlah')->summarize(
Count::make()->query(fn (Database\Query\Builder $query) => $query->groupBy('type'))->label('')
),
])
->filters([
//
])
->actions([
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->defaultGroup(
// Group the rows by Year and Month (2023-09, 2023-11 etc) instead of "date"
Group::make('date_register')
// Ex: "2023-10-0",
// Note: You need the "-0" at the end, so Carbon can parse the date.
->getKeyFromRecordUsing(
fn(RegistrationData $record): string => $record->date_register
)
// Ex: "September 2023"
->getTitleFromRecordUsing(
fn(RegistrationData $record): string => $record->date_register->format('F Y')
)
// Set the default ordering
->orderQueryUsing(
fn(Builder $query, string $direction) => $query->orderBy('date_register', 'asc')
)
// Hide "date: " in the Group title
->titlePrefixedWithLabel(false)
->collapsible(),
);
}and the result like the image, I think the summary that each group by date is not appropriate, how can I solve it?
