F
Filament6mo ago
ericmp

Trouble trying to summarize

in my members table resource im trying to coun how many id_test i have what im trying:
Tables\Columns\TextColumn::make('id_test')
->summarize(Tables\Columns\Summarizers\Count::make())
->searchable(),
Tables\Columns\TextColumn::make('id_test')
->summarize(Tables\Columns\Summarizers\Count::make())
->searchable(),
what i get afaik i go to the table in the frontend:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`members`' at line 1

SELECT
count(bgcrm.members.id_test) AS "r9YurdB29qr0ftXE"
FROM
(
SELECT
*
FROM
`bgcrm`.`members`
WHERE
`bgcrm`.`members`.`deleted_at` IS NULL
ORDER BY
`bgcrm`.`members`.`id` ASC
limit
10 OFFSET 0
) AS `bgcrm`.`members`;
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`members`' at line 1

SELECT
count(bgcrm.members.id_test) AS "r9YurdB29qr0ftXE"
FROM
(
SELECT
*
FROM
`bgcrm`.`members`
WHERE
`bgcrm`.`members`.`deleted_at` IS NULL
ORDER BY
`bgcrm`.`members`.`id` ASC
limit
10 OFFSET 0
) AS `bgcrm`.`members`;
i've found the issue but idk how to solve it. my Member model uses this as table name protected $table = 'bgcrm.members';, and i cannot change it. but if i change it to: protected $table = 'members';, it works i cannot change it cuz i need it to make relationships to work when working with relationships between different databases. if i change it to protected $table = 'members'; then some relationships wont work cuz they'll search on their default db database, and i need them to search in bgcrm database
3 Replies
ericmp
ericmpOP6mo ago
bump
Kymset
Kymset6mo ago
Not sure I can help much as I haven't delved into summaries yet. This may not be the right solution but have a look at custom summaries: https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries Using this you maybe able to make your own query:
TextColumn::make('id_text')
->summarize(Summarizer::make()
->label('Count Test')
->using(fn (Builder $query): string => $query->count('id_test')))
TextColumn::make('id_text')
->summarize(Summarizer::make()
->label('Count Test')
->using(fn (Builder $query): string => $query->count('id_test')))
Hope it helps
ericmp
ericmpOP6mo ago
thanks for the response. but yeah im getting the same error :I
Want results from more Discord servers?
Add your server