Doubts with summarize(Count)

I want to put 3 summarize columns in a table with only two columns. How do I do it? I tried to create two empty columns in the table, but only 2 summarize fields appear. My code: return $table ->columns([ Tables\Columns\TextColumn::make('name') ->label('Nombre') ->searchable(), Tables\Columns\TextColumn::make('type') ->label('Tipo') ->summarize( Count::make('uno')->label('Nº total de clientes')->query(fn ($query) => $query), ) ->sortable() ->searchable(), TextColumn::make('') ->label('') ->summarize( Count::make()->label('Nº total de ayuntamientos')->query(fn ($query) => $query->where('type', 0)), ), TextColumn::make('') ->label('') ->summarize( Count::make()->label('Nº total de NO ayuntamientos')->query(fn ($query) => $query->where('type', 1)), ) ])->paginated([25, 35, 50, 100])->defaultSort('name', 'ASC')
Solution:
Ok, thank you guys. But in the end, I'm leaving it as it is, the client hasn't bothered.
Jump to solution
13 Replies
astronomic
astronomic3mo ago
Don't show me the 3 columns, only two. Image
No description
astronomic
astronomic3mo ago
I have achieved it by putting a name in make(), but there is a very large empty space, and the client does not want that. Is there a way to put two counts() in the same column? Does anyone know any solution? nobody?
HeyWeb
HeyWeb3mo ago
Did you try adding a widget to the header?
Tieme
Tieme3mo ago
Have you read the docs (https://filamentphp.com/docs/3.x/tables/summaries)?
Tables\Columns\TextColumn::make('type')
->label('Tipo')
->summarize(
Count::make('uno')->label('Nº total de clientes')->query(fn ($query) => $query),
Count::make()->label('Nº total de ayuntamientos')->query(fn ($query) => $query->where('type', 0)),
Count::make()->label('Nº total de NO ayuntamientos')->query(fn ($query) => $query->where('type', 1)),
)
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('type')
->label('Tipo')
->summarize(
Count::make('uno')->label('Nº total de clientes')->query(fn ($query) => $query),
Count::make()->label('Nº total de ayuntamientos')->query(fn ($query) => $query->where('type', 0)),
Count::make()->label('Nº total de NO ayuntamientos')->query(fn ($query) => $query->where('type', 1)),
)
->sortable()
->searchable(),
Dennis Koch
Dennis Koch3mo ago
You should give your text columns a unique name. An empty string is no good idea.
astronomic
astronomic2mo ago
ok, thank you. But I have put it because they are "ghost" columns, no name has to appear It doesn't work for me if I put the 'counts' all together, and yes, I read No, because it will depend on the filters.
Dennis Koch
Dennis Koch2mo ago
Then set an empty label. They still need a name
astronomic
astronomic2mo ago
It's already done like that, even though it's not in the post. But that's not my problem. I don't want the space from the two 'ghost' columns to show up in the table. I would need another option. Thanks anyway.
astronomic
astronomic2mo ago
This space
No description
Dennis Koch
Dennis Koch2mo ago
Then It’s not a table layout anymore. I doubt we have a solution for that Maybe you can put 3 summarizers in the first column.
Tieme
Tieme2mo ago
Or create some widgets something like this Example code can be found here : https://github.com/timwassenburg/filament-timesheets?tab=readme-ov-file
GitHub
GitHub - timwassenburg/filament-timesheets: Laravel Timesheets for ...
Laravel Timesheets for Filament. Contribute to timwassenburg/filament-timesheets development by creating an account on GitHub.
No description
Solution
astronomic
astronomic2mo ago
Ok, thank you guys. But in the end, I'm leaving it as it is, the client hasn't bothered.
Want results from more Discord servers?
Add your server
More Posts